effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
FStar.Pervasives.Lemma
val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i)))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end
val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i =
false
null
true
let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then (Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; ()) else let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); exp_lr_lemma_loop k a bBits b (i - 1); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; ()
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.op_LessThanOrEqual", "Prims.op_Equality", "Prims.int", "Prims.unit", "Lib.Exponentiation.Definition.lemma_pow0", "Lib.LoopCombinators.eq_repeati0", "Lib.Exponentiation.exp_lr_f", "Lib.Exponentiation.Definition.one", "Prims.bool", "Lib.Exponentiation.exp_lr_lemma_step", "Prims.op_Subtraction", "Lib.Exponentiation.exp_lr_lemma_loop", "Lib.LoopCombinators.unfold_repeati", "Lib.LoopCombinators.repeati" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i)))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i)))
[ "recursion" ]
Lib.Exponentiation.exp_lr_lemma_loop
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i <= bBits} -> FStar.Pervasives.Lemma (ensures (let acc = Lib.LoopCombinators.repeati i (Lib.Exponentiation.exp_lr_f k a bBits b) Lib.Exponentiation.Definition.one in acc == Lib.Exponentiation.Definition.pow k a (b / Prims.pow2 (bBits - i))))
{ "end_col": 10, "end_line": 144, "start_col": 44, "start_line": 130 }
FStar.Pervasives.Lemma
val exp_double_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in acc0 == mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_double_fw_acc0_lemma #t k a1 bBits b1 a2 b2 l = let bk = bBits - bBits % l in if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b1 (pow2 bBits); assert (b1 / pow2 (bBits / l * l) == 0); assert (b2 / pow2 (bBits / l * l) == 0); lemma_pow0 k a1; lemma_pow0 k a2; lemma_one k.one; assert (acc == mul (pow k a1 (b1 / pow2 bk)) (pow k a2 (b2 / pow2 bk))); () end else begin exp_fw_acc0_lemma #t k a1 bBits b1 l; exp_fw_acc0_lemma #t k a2 bBits b2 l end
val exp_double_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in acc0 == mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) let exp_double_fw_acc0_lemma #t k a1 bBits b1 a2 b2 l =
false
null
true
let bk = bBits - bBits % l in if bBits % l = 0 then let acc = one in assert ((bBits / l) * l == bBits); Math.Lemmas.small_div b1 (pow2 bBits); assert (b1 / pow2 ((bBits / l) * l) == 0); assert (b2 / pow2 ((bBits / l) * l) == 0); lemma_pow0 k a1; lemma_pow0 k a2; lemma_one k.one; assert (acc == mul (pow k a1 (b1 / pow2 bk)) (pow k a2 (b2 / pow2 bk))); () else (exp_fw_acc0_lemma #t k a1 bBits b1 l; exp_fw_acc0_lemma #t k a2 bBits b2 l)
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.unit", "Prims._assert", "Prims.eq2", "Lib.Exponentiation.Definition.mul", "Lib.Exponentiation.Definition.pow", "Prims.op_Division", "Lib.Exponentiation.Definition.lemma_one", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__one", "Lib.Exponentiation.Definition.lemma_pow0", "FStar.Mul.op_Star", "FStar.Math.Lemmas.small_div", "Lib.Exponentiation.Definition.one", "Prims.bool", "Lib.Exponentiation.exp_fw_acc0_lemma", "Prims.op_Subtraction" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end let exp_mont_ladder_swap_lemma #t k a bBits b = exp_mont_ladder_swap_lemma_loop #t k a bBits b 0 bBits //------------------------------ val exp_pow2_loop_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> i:nat{i <= b} -> Lemma (Loops.repeat i (sqr k) a == pow k a (pow2 i)) let rec exp_pow2_loop_lemma #t k a b i = if i = 0 then begin Loops.eq_repeat0 (sqr k) a; assert_norm (pow2 0 = 1); lemma_pow1 k a end else begin Loops.unfold_repeat b (sqr k) a (i - 1); exp_pow2_loop_lemma k a b (i - 1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); () end let exp_pow2_lemma #t k a b = exp_pow2_loop_lemma k a b b // Fixed-window method //--------------------- val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i)) let exp_fw_lemma_step #t k a bBits b l i acc1 = let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc (==) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); (==) { } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); (==) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); (==) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); (==) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); } val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i)) let rec exp_fw_lemma_loop #t k a bBits b l i = let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_fw_f k a bBits b l) acc0 else begin Loops.unfold_repeati i (exp_fw_f k a bBits b l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_fw_f k a bBits b l) acc0 in assert (acc == exp_fw_f k a bBits b l (i - 1) acc1); exp_fw_lemma_loop k a bBits b l (i - 1); exp_fw_lemma_step k a bBits b l i acc1; () end val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_lemma #t k a bBits b l = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in let acc = pow k a bits_c in assert (bits_c == b / pow2 (bBits / l * l) % pow2 l); Math.Lemmas.lemma_div_lt_nat b bBits (bBits / l * l); assert (b / pow2 (bBits / l * l) < pow2 (bBits % l)); Math.Lemmas.pow2_lt_compat l (bBits % l); Math.Lemmas.small_mod (b / pow2 (bBits / l * l)) (pow2 l); assert (bits_c == b / pow2 (bBits / l * l)); assert (acc == pow k a (b / pow2 (bBits / l * l))); () val exp_fw_acc0_aux_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in acc0 == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_aux_lemma #t k a bBits b l = if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b (pow2 bBits); assert (b / pow2 (bBits / l * l) == 0); lemma_pow0 k a; assert (acc == pow k a (b / pow2 (bBits / l * l))); () end else exp_fw_acc0_lemma #t k a bBits b l let exp_fw_lemma #t k a bBits b l = let b_rem = b_acc l bBits b 0 in let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in exp_fw_acc0_aux_lemma k a bBits b l; assert (acc0 == pow k a b_rem); let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in exp_fw_lemma_loop k a bBits b l (bBits / l); assert (res == pow k a (b_acc l bBits b (bBits / l))); Math.Lemmas.euclidean_division_definition bBits l; assert (res == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- val lemma_pow_distr_mul: #t:Type -> k:comm_monoid t -> x:t -> a:t -> r1:nat -> r2:nat -> r3:nat -> Lemma (k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2) == k.mul (pow k a (r1 * r3 + r2)) x) let lemma_pow_distr_mul #t k x a r1 r2 r3 = calc (==) { k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2); (==) { lemma_pow_mul k a r1 r3 } k.mul (k.mul x (pow k a (r1 * r3))) (pow k a r2); (==) { k.lemma_mul_assoc x (pow k a (r1 * r3)) (pow k a r2) } k.mul x (k.mul (pow k a (r1 * r3)) (pow k a r2)); (==) { lemma_pow_add k a (r1 * r3) r2 } k.mul x (pow k a (r1 * r3 + r2)); (==) { k.lemma_mul_comm x (pow k a (r1 * r3 + r2)) } k.mul (pow k a (r1 * r3 + r2)) x; } val exp_double_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (ensures exp_double_fw_f k a1 bBits b1 a2 b2 l (i - 1) acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let exp_double_fw_lemma_step #t k a1 bBits b1 a2 b2 l i acc = let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in calc (==) { k.mul acc1 (pow k a2 r22); (==) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a2 r22); (==) { } k.mul (pow k (k.mul (pow k a1 r11) (pow k a2 r21)) (pow2 l)) (pow k a2 r22); (==) { lemma_pow_mul_base k (pow k a1 r11) (pow k a2 r21) (pow2 l) } k.mul (k.mul (pow k (pow k a1 r11) (pow2 l)) (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22); (==) { lemma_pow_distr_mul k (pow k (pow k a1 r11) (pow2 l)) a2 r21 r22 (pow2 l) } k.mul (pow k a2 (r21 * pow2 l + r22)) (pow k (pow k a1 r11) (pow2 l)); (==) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a2 (pow k (pow k a1 r11) (pow2 l)); }; calc (==) { k.mul (k.mul acc1 (pow k a2 r22)) (pow k a1 r12); (==) { } k.mul (k.mul res_a2 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); (==) { lemma_pow_distr_mul k res_a2 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a2; (==) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 res_a2; } val exp_double_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let rec exp_double_fw_lemma_loop #t k a1 bBits b1 a2 b2 l i = let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 else begin Loops.unfold_repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in exp_double_fw_lemma_loop k a1 bBits b1 a2 b2 l (i - 1); exp_double_fw_lemma_step k a1 bBits b1 a2 b2 l i acc1; () end val exp_double_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in acc0 == mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_double_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in acc0 == mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)))
[]
Lib.Exponentiation.exp_double_fw_acc0_lemma
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> l: Prims.pos -> FStar.Pervasives.Lemma (ensures (let acc0 = (match bBits % l = 0 with | true -> Lib.Exponentiation.Definition.one | _ -> Lib.Exponentiation.exp_double_fw_acc0 k a1 bBits b1 a2 b2 l) <: t in acc0 == Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.pow k a1 (Lib.Exponentiation.b_acc l bBits b1 0)) (Lib.Exponentiation.Definition.pow k a2 (Lib.Exponentiation.b_acc l bBits b2 0))))
{ "end_col": 44, "end_line": 518, "start_col": 55, "start_line": 503 }
FStar.Pervasives.Lemma
val lemma_pow_distr_mul: #t:Type -> k:comm_monoid t -> x:t -> a:t -> r1:nat -> r2:nat -> r3:nat -> Lemma (k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2) == k.mul (pow k a (r1 * r3 + r2)) x)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_pow_distr_mul #t k x a r1 r2 r3 = calc (==) { k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2); (==) { lemma_pow_mul k a r1 r3 } k.mul (k.mul x (pow k a (r1 * r3))) (pow k a r2); (==) { k.lemma_mul_assoc x (pow k a (r1 * r3)) (pow k a r2) } k.mul x (k.mul (pow k a (r1 * r3)) (pow k a r2)); (==) { lemma_pow_add k a (r1 * r3) r2 } k.mul x (pow k a (r1 * r3 + r2)); (==) { k.lemma_mul_comm x (pow k a (r1 * r3 + r2)) } k.mul (pow k a (r1 * r3 + r2)) x; }
val lemma_pow_distr_mul: #t:Type -> k:comm_monoid t -> x:t -> a:t -> r1:nat -> r2:nat -> r3:nat -> Lemma (k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2) == k.mul (pow k a (r1 * r3 + r2)) x) let lemma_pow_distr_mul #t k x a r1 r2 r3 =
false
null
true
calc ( == ) { k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2); ( == ) { lemma_pow_mul k a r1 r3 } k.mul (k.mul x (pow k a (r1 * r3))) (pow k a r2); ( == ) { k.lemma_mul_assoc x (pow k a (r1 * r3)) (pow k a r2) } k.mul x (k.mul (pow k a (r1 * r3)) (pow k a r2)); ( == ) { lemma_pow_add k a (r1 * r3) r2 } k.mul x (pow k a (r1 * r3 + r2)); ( == ) { k.lemma_mul_comm x (pow k a (r1 * r3 + r2)) } k.mul (pow k a (r1 * r3 + r2)) x; }
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "FStar.Calc.calc_finish", "Prims.eq2", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__mul", "Lib.Exponentiation.Definition.pow", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Lib.Exponentiation.Definition.lemma_pow_mul", "Prims.squash", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__lemma_mul_assoc", "Lib.Exponentiation.Definition.lemma_pow_add", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__lemma_mul_comm" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end let exp_mont_ladder_swap_lemma #t k a bBits b = exp_mont_ladder_swap_lemma_loop #t k a bBits b 0 bBits //------------------------------ val exp_pow2_loop_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> i:nat{i <= b} -> Lemma (Loops.repeat i (sqr k) a == pow k a (pow2 i)) let rec exp_pow2_loop_lemma #t k a b i = if i = 0 then begin Loops.eq_repeat0 (sqr k) a; assert_norm (pow2 0 = 1); lemma_pow1 k a end else begin Loops.unfold_repeat b (sqr k) a (i - 1); exp_pow2_loop_lemma k a b (i - 1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); () end let exp_pow2_lemma #t k a b = exp_pow2_loop_lemma k a b b // Fixed-window method //--------------------- val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i)) let exp_fw_lemma_step #t k a bBits b l i acc1 = let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc (==) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); (==) { } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); (==) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); (==) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); (==) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); } val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i)) let rec exp_fw_lemma_loop #t k a bBits b l i = let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_fw_f k a bBits b l) acc0 else begin Loops.unfold_repeati i (exp_fw_f k a bBits b l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_fw_f k a bBits b l) acc0 in assert (acc == exp_fw_f k a bBits b l (i - 1) acc1); exp_fw_lemma_loop k a bBits b l (i - 1); exp_fw_lemma_step k a bBits b l i acc1; () end val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_lemma #t k a bBits b l = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in let acc = pow k a bits_c in assert (bits_c == b / pow2 (bBits / l * l) % pow2 l); Math.Lemmas.lemma_div_lt_nat b bBits (bBits / l * l); assert (b / pow2 (bBits / l * l) < pow2 (bBits % l)); Math.Lemmas.pow2_lt_compat l (bBits % l); Math.Lemmas.small_mod (b / pow2 (bBits / l * l)) (pow2 l); assert (bits_c == b / pow2 (bBits / l * l)); assert (acc == pow k a (b / pow2 (bBits / l * l))); () val exp_fw_acc0_aux_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in acc0 == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_aux_lemma #t k a bBits b l = if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b (pow2 bBits); assert (b / pow2 (bBits / l * l) == 0); lemma_pow0 k a; assert (acc == pow k a (b / pow2 (bBits / l * l))); () end else exp_fw_acc0_lemma #t k a bBits b l let exp_fw_lemma #t k a bBits b l = let b_rem = b_acc l bBits b 0 in let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in exp_fw_acc0_aux_lemma k a bBits b l; assert (acc0 == pow k a b_rem); let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in exp_fw_lemma_loop k a bBits b l (bBits / l); assert (res == pow k a (b_acc l bBits b (bBits / l))); Math.Lemmas.euclidean_division_definition bBits l; assert (res == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- val lemma_pow_distr_mul: #t:Type -> k:comm_monoid t -> x:t -> a:t -> r1:nat -> r2:nat -> r3:nat -> Lemma (k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2) == k.mul (pow k a (r1 * r3 + r2)) x)
false
false
Lib.Exponentiation.fst
{ "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" }
null
val lemma_pow_distr_mul: #t:Type -> k:comm_monoid t -> x:t -> a:t -> r1:nat -> r2:nat -> r3:nat -> Lemma (k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2) == k.mul (pow k a (r1 * r3 + r2)) x)
[]
Lib.Exponentiation.lemma_pow_distr_mul
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> x: t -> a: t -> r1: Prims.nat -> r2: Prims.nat -> r3: Prims.nat -> FStar.Pervasives.Lemma (ensures Mkcomm_monoid?.mul k (Mkcomm_monoid?.mul k x (Lib.Exponentiation.Definition.pow k (Lib.Exponentiation.Definition.pow k a r1) r3)) (Lib.Exponentiation.Definition.pow k a r2) == Mkcomm_monoid?.mul k (Lib.Exponentiation.Definition.pow k a (r1 * r3 + r2)) x)
{ "end_col": 3, "end_line": 423, "start_col": 2, "start_line": 413 }
FStar.Pervasives.Lemma
val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec exp_fw_lemma_loop #t k a bBits b l i = let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_fw_f k a bBits b l) acc0 else begin Loops.unfold_repeati i (exp_fw_f k a bBits b l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_fw_f k a bBits b l) acc0 in assert (acc == exp_fw_f k a bBits b l (i - 1) acc1); exp_fw_lemma_loop k a bBits b l (i - 1); exp_fw_lemma_step k a bBits b l i acc1; () end
val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i)) let rec exp_fw_lemma_loop #t k a bBits b l i =
false
null
true
let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_fw_f k a bBits b l) acc0 else (Loops.unfold_repeati i (exp_fw_f k a bBits b l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_fw_f k a bBits b l) acc0 in assert (acc == exp_fw_f k a bBits b l (i - 1) acc1); exp_fw_lemma_loop k a bBits b l (i - 1); exp_fw_lemma_step k a bBits b l i acc1; ())
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Prims.op_Equality", "Prims.int", "Lib.LoopCombinators.eq_repeati0", "Lib.Exponentiation.exp_fw_f", "Prims.bool", "Prims.unit", "Lib.Exponentiation.exp_fw_lemma_step", "Lib.Exponentiation.exp_fw_lemma_loop", "Prims.op_Subtraction", "Prims._assert", "Prims.eq2", "Lib.LoopCombinators.repeati", "Lib.LoopCombinators.unfold_repeati", "Lib.Exponentiation.Definition.pow", "Lib.Exponentiation.b_acc" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end let exp_mont_ladder_swap_lemma #t k a bBits b = exp_mont_ladder_swap_lemma_loop #t k a bBits b 0 bBits //------------------------------ val exp_pow2_loop_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> i:nat{i <= b} -> Lemma (Loops.repeat i (sqr k) a == pow k a (pow2 i)) let rec exp_pow2_loop_lemma #t k a b i = if i = 0 then begin Loops.eq_repeat0 (sqr k) a; assert_norm (pow2 0 = 1); lemma_pow1 k a end else begin Loops.unfold_repeat b (sqr k) a (i - 1); exp_pow2_loop_lemma k a b (i - 1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); () end let exp_pow2_lemma #t k a b = exp_pow2_loop_lemma k a b b // Fixed-window method //--------------------- val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i)) let exp_fw_lemma_step #t k a bBits b l i acc1 = let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc (==) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); (==) { } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); (==) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); (==) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); (==) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); } val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i))
[ "recursion" ]
Lib.Exponentiation.exp_fw_lemma_loop
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i <= bBits / l} -> FStar.Pervasives.Lemma (ensures (let acc0 = Lib.Exponentiation.Definition.pow k a (Lib.Exponentiation.b_acc l bBits b 0) in let acc = Lib.LoopCombinators.repeati i (Lib.Exponentiation.exp_fw_f k a bBits b l) acc0 in acc == Lib.Exponentiation.Definition.pow k a (Lib.Exponentiation.b_acc l bBits b i)))
{ "end_col": 10, "end_line": 351, "start_col": 46, "start_line": 340 }
FStar.Pervasives.Lemma
val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end
val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i =
false
null
true
if i = 0 then (Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); ()) else (Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); ())
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.op_LessThanOrEqual", "Prims.op_Equality", "Prims.int", "Prims.unit", "Lib.LoopCombinators.eq_repeati0", "FStar.Pervasives.Native.tuple2", "Lib.Exponentiation.exp_mont_ladder_f", "FStar.Pervasives.Native.Mktuple2", "Lib.Exponentiation.Definition.one", "Lib.Exponentiation.exp_mont_ladder_swap2_f", "Prims.bool", "Lib.Exponentiation.exp_mont_ladder_swap2_lemma_loop", "Prims.op_Subtraction", "Lib.LoopCombinators.unfold_repeati" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4)
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4)
[ "recursion" ]
Lib.Exponentiation.exp_mont_ladder_swap2_lemma_loop
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i <= bBits} -> FStar.Pervasives.Lemma (ensures (let _ = Lib.LoopCombinators.repeati i (Lib.Exponentiation.exp_mont_ladder_swap2_f k bBits b) (Lib.Exponentiation.Definition.one, a) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r0 r1 = _ in let _ = Lib.LoopCombinators.repeati i (Lib.Exponentiation.exp_mont_ladder_f k bBits b) (Lib.Exponentiation.Definition.one, a) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r3 r4 = _ in r0 == r3 /\ r1 == r4) <: Type0) <: Type0))
{ "end_col": 10, "end_line": 247, "start_col": 2, "start_line": 239 }
FStar.Pervasives.Lemma
val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1))))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end
val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i =
false
null
true
let r0', r1' = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == (b / pow2 (bBits - i)) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a ((b / pow2 (bBits - i)) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then (assert (r0' == pow k a (b / pow2 (bBits - i - 1))); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; ()) else (assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a ((b / pow2 (bBits - i)) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; ())
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.op_Division", "Prims.op_Subtraction", "Prims.unit", "Lib.Exponentiation.Definition.lemma_mul_comm", "Prims._assert", "Prims.eq2", "Lib.Exponentiation.Definition.mul", "Lib.Exponentiation.Definition.lemma_mul_assoc", "Lib.Exponentiation.Definition.pow", "Prims.bool", "Lib.Exponentiation.Definition.lemma_pow_add", "FStar.Mul.op_Star", "Lib.Exponentiation.Definition.lemma_pow1", "Prims.op_Addition", "Lib.Exponentiation.lemma_b_div_pow2i", "FStar.Pervasives.Native.tuple2", "Lib.Exponentiation.exp_mont_ladder_f", "FStar.Pervasives.Native.Mktuple2" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1))))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1))))
[]
Lib.Exponentiation.exp_mont_ladder_lemma_step
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> a: t -> r0: t -> r1: t -> i: Prims.nat{i < bBits} -> FStar.Pervasives.Lemma (requires r1 == Lib.Exponentiation.Definition.mul r0 a /\ r0 == Lib.Exponentiation.Definition.pow k a (b / Prims.pow2 (bBits - i))) (ensures (let _ = Lib.Exponentiation.exp_mont_ladder_f k bBits b i (r0, r1) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r0' r1' = _ in r1' == Lib.Exponentiation.Definition.mul r0' a /\ r0' == Lib.Exponentiation.Definition.pow k a (b / Prims.pow2 (bBits - i - 1))) <: Type0))
{ "end_col": 10, "end_line": 195, "start_col": 55, "start_line": 166 }
FStar.Pervasives.Lemma
val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i)))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end
val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i =
false
null
true
let r0, r1 = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then (Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; ()) else let r0', r1' = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); ()
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.op_LessThanOrEqual", "Prims.op_Equality", "Prims.int", "Prims.unit", "Lib.Exponentiation.Definition.lemma_mul_comm", "Lib.Exponentiation.Definition.one", "Lib.Exponentiation.Definition.lemma_one", "Lib.Exponentiation.Definition.lemma_pow0", "FStar.Math.Lemmas.small_div", "Lib.LoopCombinators.eq_repeati0", "FStar.Pervasives.Native.tuple2", "Lib.Exponentiation.exp_mont_ladder_f", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "Lib.Exponentiation.exp_mont_ladder_lemma_step", "Prims.op_Subtraction", "Lib.Exponentiation.exp_mont_ladder_lemma_loop", "Lib.LoopCombinators.unfold_repeati", "Lib.LoopCombinators.repeati" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i)))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i)))
[ "recursion" ]
Lib.Exponentiation.exp_mont_ladder_lemma_loop
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> a: t -> i: Prims.nat{i <= bBits} -> FStar.Pervasives.Lemma (ensures (let _ = Lib.LoopCombinators.repeati i (Lib.Exponentiation.exp_mont_ladder_f k bBits b) (Lib.Exponentiation.Definition.one, a) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r0 r1 = _ in r1 == Lib.Exponentiation.Definition.mul r0 a /\ r0 == Lib.Exponentiation.Definition.pow k a (b / Prims.pow2 (bBits - i))) <: Type0))
{ "end_col": 10, "end_line": 219, "start_col": 53, "start_line": 205 }
FStar.Pervasives.Lemma
val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); }
val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i =
false
null
true
calc ( == ) { b % pow2 i; ( == ) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } (b % pow2 i / pow2 (i - 1)) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); ( == ) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } (b % pow2 i / pow2 (i - 1)) * pow2 (i - 1) + b % pow2 (i - 1); ( == ) { (Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2)) } (b / pow2 (i - 1) % 2) * pow2 (i - 1) + b % pow2 (i - 1); }
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_LessThanOrEqual", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Modulus", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.op_Division", "Prims.op_Subtraction", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.euclidean_division_definition", "Prims.squash", "FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "FStar.Math.Lemmas.pow2_modulo_division_lemma_1" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1))
[]
Lib.Exponentiation.lemma_b_mod_pow2i
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.pos{i <= bBits} -> FStar.Pervasives.Lemma (ensures b % Prims.pow2 i == (b / Prims.pow2 (i - 1) % 2) * Prims.pow2 (i - 1) + b % Prims.pow2 (i - 1) )
{ "end_col": 3, "end_line": 20, "start_col": 2, "start_line": 12 }
FStar.Pervasives.Lemma
val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end
val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i =
false
null
true
if i = 0 then (Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); ()) else (Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); ())
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Prims.op_Division", "Prims.op_LessThanOrEqual", "Prims.op_Equality", "Prims.unit", "Lib.LoopCombinators.eq_repeati0", "FStar.Pervasives.Native.tuple2", "Lib.Exponentiation.exp_mont_ladder_f", "Lib.Exponentiation.cswap", "Lib.Exponentiation.Definition.one", "FStar.Pervasives.Native.tuple3", "Lib.Exponentiation.exp_mont_ladder_swap_f", "FStar.Pervasives.Native.Mktuple3", "Prims.bool", "Lib.Exponentiation.exp_mont_ladder_swap_lemma_loop", "Prims.op_Subtraction", "Lib.LoopCombinators.unfold_repeati" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4))
[ "recursion" ]
Lib.Exponentiation.exp_mont_ladder_swap_lemma_loop
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> sw0: Prims.nat{sw0 == b / Prims.pow2 bBits % 2} -> i: Prims.nat{i <= bBits} -> FStar.Pervasives.Lemma (ensures (let _ = Lib.LoopCombinators.repeati i (Lib.Exponentiation.exp_mont_ladder_swap_f k bBits b) (Lib.Exponentiation.Definition.one, a, sw0) in (let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ r0 r1 sw = _ in let _ = Lib.LoopCombinators.repeati i (Lib.Exponentiation.exp_mont_ladder_f k bBits b) (Lib.Exponentiation.cswap sw0 Lib.Exponentiation.Definition.one a) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r3 r4 = _ in let bit = b / Prims.pow2 (bBits - i) % 2 in sw == bit /\ Lib.Exponentiation.cswap bit r0 r1 == FStar.Pervasives.Native.Mktuple2 r3 r4) <: Type0) <: Type0))
{ "end_col": 10, "end_line": 274, "start_col": 2, "start_line": 266 }
FStar.Pervasives.Lemma
val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end
val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a =
false
null
true
let acc, c = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then (Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; ()) else let acc1, c1 = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == (b / pow2 (i - 1) % 2) * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then (assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); ())
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.op_LessThanOrEqual", "Prims.op_Equality", "Prims.int", "Prims.unit", "Lib.Exponentiation.Definition.lemma_pow1", "Lib.Exponentiation.Definition.lemma_pow0", "FStar.Pervasives.assert_norm", "Lib.LoopCombinators.eq_repeati0", "FStar.Pervasives.Native.tuple2", "Lib.Exponentiation.exp_rl_f", "FStar.Pervasives.Native.Mktuple2", "Lib.Exponentiation.Definition.one", "Prims.bool", "Prims.op_Modulus", "Prims.op_Division", "Prims.op_Subtraction", "Prims._assert", "Prims.eq2", "Lib.Exponentiation.Definition.pow", "Lib.Exponentiation.Definition.lemma_pow_add", "Lib.Exponentiation.Definition.mul", "Prims.op_Addition", "FStar.Mul.op_Star", "Lib.Exponentiation.lemma_b_mod_pow2i", "FStar.Math.Lemmas.pow2_double_sum", "Prims.l_and", "Lib.Exponentiation.exp_rl_lemma_loop", "Lib.LoopCombinators.unfold_repeati", "Lib.LoopCombinators.repeati" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i))
[ "recursion" ]
Lib.Exponentiation.exp_rl_lemma_loop
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i <= bBits} -> a: t -> FStar.Pervasives.Lemma (ensures (let _ = Lib.LoopCombinators.repeati i (Lib.Exponentiation.exp_rl_f k bBits b) (Lib.Exponentiation.Definition.one, a) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ acc c = _ in acc == Lib.Exponentiation.Definition.pow k a (b % Prims.pow2 i) /\ c == Lib.Exponentiation.Definition.pow k a (Prims.pow2 i)) <: Type0))
{ "end_col": 15, "end_line": 89, "start_col": 44, "start_line": 59 }
FStar.Pervasives.Lemma
val exp_double_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i)))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec exp_double_fw_lemma_loop #t k a1 bBits b1 a2 b2 l i = let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 else begin Loops.unfold_repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in exp_double_fw_lemma_loop k a1 bBits b1 a2 b2 l (i - 1); exp_double_fw_lemma_step k a1 bBits b1 a2 b2 l i acc1; () end
val exp_double_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let rec exp_double_fw_lemma_loop #t k a1 bBits b1 a2 b2 l i =
false
null
true
let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 else (Loops.unfold_repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in exp_double_fw_lemma_loop k a1 bBits b1 a2 b2 l (i - 1); exp_double_fw_lemma_step k a1 bBits b1 a2 b2 l i acc1; ())
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Prims.op_Equality", "Prims.int", "Lib.LoopCombinators.eq_repeati0", "Lib.Exponentiation.exp_double_fw_f", "Prims.bool", "Prims.unit", "Lib.Exponentiation.exp_double_fw_lemma_step", "Lib.Exponentiation.exp_double_fw_lemma_loop", "Prims.op_Subtraction", "Lib.LoopCombinators.repeati", "Lib.LoopCombinators.unfold_repeati", "Lib.Exponentiation.Definition.mul", "Lib.Exponentiation.Definition.pow", "Lib.Exponentiation.b_acc" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end let exp_mont_ladder_swap_lemma #t k a bBits b = exp_mont_ladder_swap_lemma_loop #t k a bBits b 0 bBits //------------------------------ val exp_pow2_loop_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> i:nat{i <= b} -> Lemma (Loops.repeat i (sqr k) a == pow k a (pow2 i)) let rec exp_pow2_loop_lemma #t k a b i = if i = 0 then begin Loops.eq_repeat0 (sqr k) a; assert_norm (pow2 0 = 1); lemma_pow1 k a end else begin Loops.unfold_repeat b (sqr k) a (i - 1); exp_pow2_loop_lemma k a b (i - 1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); () end let exp_pow2_lemma #t k a b = exp_pow2_loop_lemma k a b b // Fixed-window method //--------------------- val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i)) let exp_fw_lemma_step #t k a bBits b l i acc1 = let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc (==) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); (==) { } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); (==) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); (==) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); (==) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); } val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i)) let rec exp_fw_lemma_loop #t k a bBits b l i = let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_fw_f k a bBits b l) acc0 else begin Loops.unfold_repeati i (exp_fw_f k a bBits b l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_fw_f k a bBits b l) acc0 in assert (acc == exp_fw_f k a bBits b l (i - 1) acc1); exp_fw_lemma_loop k a bBits b l (i - 1); exp_fw_lemma_step k a bBits b l i acc1; () end val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_lemma #t k a bBits b l = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in let acc = pow k a bits_c in assert (bits_c == b / pow2 (bBits / l * l) % pow2 l); Math.Lemmas.lemma_div_lt_nat b bBits (bBits / l * l); assert (b / pow2 (bBits / l * l) < pow2 (bBits % l)); Math.Lemmas.pow2_lt_compat l (bBits % l); Math.Lemmas.small_mod (b / pow2 (bBits / l * l)) (pow2 l); assert (bits_c == b / pow2 (bBits / l * l)); assert (acc == pow k a (b / pow2 (bBits / l * l))); () val exp_fw_acc0_aux_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in acc0 == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_aux_lemma #t k a bBits b l = if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b (pow2 bBits); assert (b / pow2 (bBits / l * l) == 0); lemma_pow0 k a; assert (acc == pow k a (b / pow2 (bBits / l * l))); () end else exp_fw_acc0_lemma #t k a bBits b l let exp_fw_lemma #t k a bBits b l = let b_rem = b_acc l bBits b 0 in let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in exp_fw_acc0_aux_lemma k a bBits b l; assert (acc0 == pow k a b_rem); let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in exp_fw_lemma_loop k a bBits b l (bBits / l); assert (res == pow k a (b_acc l bBits b (bBits / l))); Math.Lemmas.euclidean_division_definition bBits l; assert (res == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- val lemma_pow_distr_mul: #t:Type -> k:comm_monoid t -> x:t -> a:t -> r1:nat -> r2:nat -> r3:nat -> Lemma (k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2) == k.mul (pow k a (r1 * r3 + r2)) x) let lemma_pow_distr_mul #t k x a r1 r2 r3 = calc (==) { k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2); (==) { lemma_pow_mul k a r1 r3 } k.mul (k.mul x (pow k a (r1 * r3))) (pow k a r2); (==) { k.lemma_mul_assoc x (pow k a (r1 * r3)) (pow k a r2) } k.mul x (k.mul (pow k a (r1 * r3)) (pow k a r2)); (==) { lemma_pow_add k a (r1 * r3) r2 } k.mul x (pow k a (r1 * r3 + r2)); (==) { k.lemma_mul_comm x (pow k a (r1 * r3 + r2)) } k.mul (pow k a (r1 * r3 + r2)) x; } val exp_double_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (ensures exp_double_fw_f k a1 bBits b1 a2 b2 l (i - 1) acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let exp_double_fw_lemma_step #t k a1 bBits b1 a2 b2 l i acc = let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in calc (==) { k.mul acc1 (pow k a2 r22); (==) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a2 r22); (==) { } k.mul (pow k (k.mul (pow k a1 r11) (pow k a2 r21)) (pow2 l)) (pow k a2 r22); (==) { lemma_pow_mul_base k (pow k a1 r11) (pow k a2 r21) (pow2 l) } k.mul (k.mul (pow k (pow k a1 r11) (pow2 l)) (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22); (==) { lemma_pow_distr_mul k (pow k (pow k a1 r11) (pow2 l)) a2 r21 r22 (pow2 l) } k.mul (pow k a2 (r21 * pow2 l + r22)) (pow k (pow k a1 r11) (pow2 l)); (==) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a2 (pow k (pow k a1 r11) (pow2 l)); }; calc (==) { k.mul (k.mul acc1 (pow k a2 r22)) (pow k a1 r12); (==) { } k.mul (k.mul res_a2 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); (==) { lemma_pow_distr_mul k res_a2 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a2; (==) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 res_a2; } val exp_double_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i)))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_double_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i)))
[ "recursion" ]
Lib.Exponentiation.exp_double_fw_lemma_loop
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i <= bBits / l} -> FStar.Pervasives.Lemma (ensures (let acc0 = Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.pow k a1 (Lib.Exponentiation.b_acc l bBits b1 0)) (Lib.Exponentiation.Definition.pow k a2 (Lib.Exponentiation.b_acc l bBits b2 0)) in let acc = Lib.LoopCombinators.repeati i (Lib.Exponentiation.exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in acc == Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.pow k a1 (Lib.Exponentiation.b_acc l bBits b1 i)) (Lib.Exponentiation.Definition.pow k a2 (Lib.Exponentiation.b_acc l bBits b2 i))))
{ "end_col": 10, "end_line": 494, "start_col": 61, "start_line": 483 }
FStar.Pervasives.Lemma
val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_fw_acc0_lemma #t k a bBits b l = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in let acc = pow k a bits_c in assert (bits_c == b / pow2 (bBits / l * l) % pow2 l); Math.Lemmas.lemma_div_lt_nat b bBits (bBits / l * l); assert (b / pow2 (bBits / l * l) < pow2 (bBits % l)); Math.Lemmas.pow2_lt_compat l (bBits % l); Math.Lemmas.small_mod (b / pow2 (bBits / l * l)) (pow2 l); assert (bits_c == b / pow2 (bBits / l * l)); assert (acc == pow k a (b / pow2 (bBits / l * l))); ()
val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_lemma #t k a bBits b l =
false
null
true
let bits_c = get_ith_lbits bBits b ((bBits / l) * l) l in let acc = pow k a bits_c in assert (bits_c == b / pow2 ((bBits / l) * l) % pow2 l); Math.Lemmas.lemma_div_lt_nat b bBits ((bBits / l) * l); assert (b / pow2 ((bBits / l) * l) < pow2 (bBits % l)); Math.Lemmas.pow2_lt_compat l (bBits % l); Math.Lemmas.small_mod (b / pow2 ((bBits / l) * l)) (pow2 l); assert (bits_c == b / pow2 ((bBits / l) * l)); assert (acc == pow k a (b / pow2 ((bBits / l) * l))); ()
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_disEquality", "Prims.int", "Prims.op_Modulus", "Prims.unit", "Prims._assert", "Prims.eq2", "Lib.Exponentiation.Definition.pow", "Prims.op_Division", "FStar.Mul.op_Star", "FStar.Math.Lemmas.small_mod", "FStar.Math.Lemmas.pow2_lt_compat", "FStar.Math.Lemmas.lemma_div_lt_nat", "Lib.Exponentiation.get_ith_lbits" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end let exp_mont_ladder_swap_lemma #t k a bBits b = exp_mont_ladder_swap_lemma_loop #t k a bBits b 0 bBits //------------------------------ val exp_pow2_loop_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> i:nat{i <= b} -> Lemma (Loops.repeat i (sqr k) a == pow k a (pow2 i)) let rec exp_pow2_loop_lemma #t k a b i = if i = 0 then begin Loops.eq_repeat0 (sqr k) a; assert_norm (pow2 0 = 1); lemma_pow1 k a end else begin Loops.unfold_repeat b (sqr k) a (i - 1); exp_pow2_loop_lemma k a b (i - 1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); () end let exp_pow2_lemma #t k a b = exp_pow2_loop_lemma k a b b // Fixed-window method //--------------------- val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i)) let exp_fw_lemma_step #t k a bBits b l i acc1 = let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc (==) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); (==) { } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); (==) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); (==) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); (==) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); } val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i)) let rec exp_fw_lemma_loop #t k a bBits b l i = let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_fw_f k a bBits b l) acc0 else begin Loops.unfold_repeati i (exp_fw_f k a bBits b l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_fw_f k a bBits b l) acc0 in assert (acc == exp_fw_f k a bBits b l (i - 1) acc1); exp_fw_lemma_loop k a bBits b l (i - 1); exp_fw_lemma_step k a bBits b l i acc1; () end val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0))
[]
Lib.Exponentiation.exp_fw_acc0_lemma
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos{bBits % l <> 0} -> FStar.Pervasives.Lemma (ensures Lib.Exponentiation.exp_fw_acc0 k a bBits b l == Lib.Exponentiation.Definition.pow k a (Lib.Exponentiation.b_acc l bBits b 0))
{ "end_col": 4, "end_line": 370, "start_col": 40, "start_line": 360 }
FStar.Pervasives.Lemma
val exp_four_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_four_fw_acc0 k a1 bBits b1 a2 b2 a3 b3 a4 b4 l in let b1_rem = b_acc l bBits b1 0 in let b2_rem = b_acc l bBits b2 0 in let b3_rem = b_acc l bBits b3 0 in let b4_rem = b_acc l bBits b4 0 in acc0 == mul (mul (pow k a1 b1_rem) (pow k a2 b2_rem)) (mul (pow k a3 b3_rem) (pow k a4 b4_rem)))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_four_fw_acc0_lemma #t k a1 bBits b1 a2 b2 a3 b3 a4 b4 l = let b1_rem = b_acc l bBits b1 0 in let b2_rem = b_acc l bBits b2 0 in let b3_rem = b_acc l bBits b3 0 in let b4_rem = b_acc l bBits b4 0 in if bBits % l = 0 then begin assert (bBits / l * l == bBits); Math.Lemmas.small_div b1 (pow2 bBits); Math.Lemmas.small_div b2 (pow2 bBits); Math.Lemmas.small_div b3 (pow2 bBits); Math.Lemmas.small_div b4 (pow2 bBits); assert (b1_rem = 0); lemma_pow0 k a1; lemma_pow0 k a2; lemma_pow0 k a3; lemma_pow0 k a4; assert ( mul (mul (pow k a1 b1_rem) (pow k a2 b2_rem)) (mul (pow k a3 b3_rem) (pow k a4 b4_rem)) == mul (mul one one) (mul one one)); lemma_one k.one; () end else begin let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in let acc_a3 = exp_fw_acc0 k a3 bBits b3 l in let acc_a4 = exp_fw_acc0 k a4 bBits b4 l in exp_fw_acc0_lemma k a1 bBits b1 l; exp_fw_acc0_lemma k a2 bBits b2 l; exp_fw_acc0_lemma k a3 bBits b3 l; exp_fw_acc0_lemma k a4 bBits b4 l; Math.Lemmas.euclidean_division_definition bBits l; assert (acc_a1 == pow k a1 b1_rem); assert (acc_a2 == pow k a2 b2_rem); assert (acc_a3 == pow k a3 b3_rem); assert (acc_a4 == pow k a4 b4_rem) end
val exp_four_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_four_fw_acc0 k a1 bBits b1 a2 b2 a3 b3 a4 b4 l in let b1_rem = b_acc l bBits b1 0 in let b2_rem = b_acc l bBits b2 0 in let b3_rem = b_acc l bBits b3 0 in let b4_rem = b_acc l bBits b4 0 in acc0 == mul (mul (pow k a1 b1_rem) (pow k a2 b2_rem)) (mul (pow k a3 b3_rem) (pow k a4 b4_rem))) let exp_four_fw_acc0_lemma #t k a1 bBits b1 a2 b2 a3 b3 a4 b4 l =
false
null
true
let b1_rem = b_acc l bBits b1 0 in let b2_rem = b_acc l bBits b2 0 in let b3_rem = b_acc l bBits b3 0 in let b4_rem = b_acc l bBits b4 0 in if bBits % l = 0 then (assert ((bBits / l) * l == bBits); Math.Lemmas.small_div b1 (pow2 bBits); Math.Lemmas.small_div b2 (pow2 bBits); Math.Lemmas.small_div b3 (pow2 bBits); Math.Lemmas.small_div b4 (pow2 bBits); assert (b1_rem = 0); lemma_pow0 k a1; lemma_pow0 k a2; lemma_pow0 k a3; lemma_pow0 k a4; assert (mul (mul (pow k a1 b1_rem) (pow k a2 b2_rem)) (mul (pow k a3 b3_rem) (pow k a4 b4_rem)) == mul (mul one one) (mul one one)); lemma_one k.one; ()) else let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in let acc_a3 = exp_fw_acc0 k a3 bBits b3 l in let acc_a4 = exp_fw_acc0 k a4 bBits b4 l in exp_fw_acc0_lemma k a1 bBits b1 l; exp_fw_acc0_lemma k a2 bBits b2 l; exp_fw_acc0_lemma k a3 bBits b3 l; exp_fw_acc0_lemma k a4 bBits b4 l; Math.Lemmas.euclidean_division_definition bBits l; assert (acc_a1 == pow k a1 b1_rem); assert (acc_a2 == pow k a2 b2_rem); assert (acc_a3 == pow k a3 b3_rem); assert (acc_a4 == pow k a4 b4_rem)
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.unit", "Lib.Exponentiation.Definition.lemma_one", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__one", "Prims._assert", "Prims.eq2", "Lib.Exponentiation.Definition.mul", "Lib.Exponentiation.Definition.pow", "Lib.Exponentiation.Definition.one", "Lib.Exponentiation.Definition.lemma_pow0", "FStar.Math.Lemmas.small_div", "FStar.Mul.op_Star", "Prims.op_Division", "Prims.bool", "FStar.Math.Lemmas.euclidean_division_definition", "Lib.Exponentiation.exp_fw_acc0_lemma", "Lib.Exponentiation.exp_fw_acc0", "Lib.Exponentiation.b_acc" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end let exp_mont_ladder_swap_lemma #t k a bBits b = exp_mont_ladder_swap_lemma_loop #t k a bBits b 0 bBits //------------------------------ val exp_pow2_loop_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> i:nat{i <= b} -> Lemma (Loops.repeat i (sqr k) a == pow k a (pow2 i)) let rec exp_pow2_loop_lemma #t k a b i = if i = 0 then begin Loops.eq_repeat0 (sqr k) a; assert_norm (pow2 0 = 1); lemma_pow1 k a end else begin Loops.unfold_repeat b (sqr k) a (i - 1); exp_pow2_loop_lemma k a b (i - 1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); () end let exp_pow2_lemma #t k a b = exp_pow2_loop_lemma k a b b // Fixed-window method //--------------------- val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i)) let exp_fw_lemma_step #t k a bBits b l i acc1 = let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc (==) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); (==) { } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); (==) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); (==) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); (==) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); } val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i)) let rec exp_fw_lemma_loop #t k a bBits b l i = let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_fw_f k a bBits b l) acc0 else begin Loops.unfold_repeati i (exp_fw_f k a bBits b l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_fw_f k a bBits b l) acc0 in assert (acc == exp_fw_f k a bBits b l (i - 1) acc1); exp_fw_lemma_loop k a bBits b l (i - 1); exp_fw_lemma_step k a bBits b l i acc1; () end val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_lemma #t k a bBits b l = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in let acc = pow k a bits_c in assert (bits_c == b / pow2 (bBits / l * l) % pow2 l); Math.Lemmas.lemma_div_lt_nat b bBits (bBits / l * l); assert (b / pow2 (bBits / l * l) < pow2 (bBits % l)); Math.Lemmas.pow2_lt_compat l (bBits % l); Math.Lemmas.small_mod (b / pow2 (bBits / l * l)) (pow2 l); assert (bits_c == b / pow2 (bBits / l * l)); assert (acc == pow k a (b / pow2 (bBits / l * l))); () val exp_fw_acc0_aux_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in acc0 == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_aux_lemma #t k a bBits b l = if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b (pow2 bBits); assert (b / pow2 (bBits / l * l) == 0); lemma_pow0 k a; assert (acc == pow k a (b / pow2 (bBits / l * l))); () end else exp_fw_acc0_lemma #t k a bBits b l let exp_fw_lemma #t k a bBits b l = let b_rem = b_acc l bBits b 0 in let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in exp_fw_acc0_aux_lemma k a bBits b l; assert (acc0 == pow k a b_rem); let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in exp_fw_lemma_loop k a bBits b l (bBits / l); assert (res == pow k a (b_acc l bBits b (bBits / l))); Math.Lemmas.euclidean_division_definition bBits l; assert (res == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- val lemma_pow_distr_mul: #t:Type -> k:comm_monoid t -> x:t -> a:t -> r1:nat -> r2:nat -> r3:nat -> Lemma (k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2) == k.mul (pow k a (r1 * r3 + r2)) x) let lemma_pow_distr_mul #t k x a r1 r2 r3 = calc (==) { k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2); (==) { lemma_pow_mul k a r1 r3 } k.mul (k.mul x (pow k a (r1 * r3))) (pow k a r2); (==) { k.lemma_mul_assoc x (pow k a (r1 * r3)) (pow k a r2) } k.mul x (k.mul (pow k a (r1 * r3)) (pow k a r2)); (==) { lemma_pow_add k a (r1 * r3) r2 } k.mul x (pow k a (r1 * r3 + r2)); (==) { k.lemma_mul_comm x (pow k a (r1 * r3 + r2)) } k.mul (pow k a (r1 * r3 + r2)) x; } val exp_double_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (ensures exp_double_fw_f k a1 bBits b1 a2 b2 l (i - 1) acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let exp_double_fw_lemma_step #t k a1 bBits b1 a2 b2 l i acc = let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in calc (==) { k.mul acc1 (pow k a2 r22); (==) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a2 r22); (==) { } k.mul (pow k (k.mul (pow k a1 r11) (pow k a2 r21)) (pow2 l)) (pow k a2 r22); (==) { lemma_pow_mul_base k (pow k a1 r11) (pow k a2 r21) (pow2 l) } k.mul (k.mul (pow k (pow k a1 r11) (pow2 l)) (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22); (==) { lemma_pow_distr_mul k (pow k (pow k a1 r11) (pow2 l)) a2 r21 r22 (pow2 l) } k.mul (pow k a2 (r21 * pow2 l + r22)) (pow k (pow k a1 r11) (pow2 l)); (==) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a2 (pow k (pow k a1 r11) (pow2 l)); }; calc (==) { k.mul (k.mul acc1 (pow k a2 r22)) (pow k a1 r12); (==) { } k.mul (k.mul res_a2 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); (==) { lemma_pow_distr_mul k res_a2 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a2; (==) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 res_a2; } val exp_double_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let rec exp_double_fw_lemma_loop #t k a1 bBits b1 a2 b2 l i = let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 else begin Loops.unfold_repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in exp_double_fw_lemma_loop k a1 bBits b1 a2 b2 l (i - 1); exp_double_fw_lemma_step k a1 bBits b1 a2 b2 l i acc1; () end val exp_double_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in acc0 == mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) let exp_double_fw_acc0_lemma #t k a1 bBits b1 a2 b2 l = let bk = bBits - bBits % l in if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b1 (pow2 bBits); assert (b1 / pow2 (bBits / l * l) == 0); assert (b2 / pow2 (bBits / l * l) == 0); lemma_pow0 k a1; lemma_pow0 k a2; lemma_one k.one; assert (acc == mul (pow k a1 (b1 / pow2 bk)) (pow k a2 (b2 / pow2 bk))); () end else begin exp_fw_acc0_lemma #t k a1 bBits b1 l; exp_fw_acc0_lemma #t k a2 bBits b2 l end let exp_double_fw_lemma #t k a1 bBits b1 a2 b2 l = let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in exp_double_fw_acc0_lemma #t k a1 bBits b1 a2 b2 l; assert (acc0 == mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))); let res = Loops.repeati (bBits / l) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in exp_double_fw_lemma_loop k a1 bBits b1 a2 b2 l (bBits / l); Math.Lemmas.euclidean_division_definition bBits l; assert_norm (pow2 0 = 1) //------------------------- val lemma_mul_assoc4: #t:Type -> k:comm_monoid t -> a1:t -> a2:t -> a3:t -> a4:t -> Lemma (k.mul a1 (k.mul (k.mul a2 a3) a4) == k.mul (k.mul (k.mul a1 a2) a3) a4) let lemma_mul_assoc4 #t k a1 a2 a3 a4 = calc (==) { k.mul a1 (k.mul (k.mul a2 a3) a4); (==) { k.lemma_mul_assoc a1 (k.mul a2 a3) a4 } k.mul (k.mul a1 (k.mul a2 a3)) a4; (==) { k.lemma_mul_assoc a1 a2 a3 } k.mul (k.mul (k.mul a1 a2) a3) a4; } val exp_four_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (pow k a3 (b_acc l bBits b3 (i - 1)))) (pow k a4 (b_acc l bBits b4 (i - 1)))) (ensures exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l (i - 1) acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i))) let exp_four_fw_lemma_step #t k a1 bBits b1 a2 b2 a3 b3 a4 b4 l i acc = let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in let r31 = b_acc l bBits b3 (i - 1) in let r32 = b_acc l bBits b3 i % pow2 l in let r41 = b_acc l bBits b4 (i - 1) in let r42 = b_acc l bBits b4 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in let res_a3 = pow k a3 (b_acc l bBits b3 i) in let res_a4 = pow k a4 (b_acc l bBits b4 i) in let acc_1 = pow k a1 r11 in let acc_1_l = pow k acc_1 (pow2 l) in let acc_12 = k.mul acc_1 (pow k a2 r21) in let acc_12_l = pow k acc_12 (pow2 l) in let acc_123 = k.mul acc_12 (pow k a3 r31) in let acc_123_l = pow k acc_123 (pow2 l) in calc (==) { k.mul acc1 (pow k a4 r42); (==) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a4 r42); (==) { } k.mul (pow k (k.mul acc_123 (pow k a4 r41)) (pow2 l)) (pow k a4 r42); (==) { lemma_pow_mul_base k acc_123 (pow k a4 r41) (pow2 l) } k.mul (k.mul acc_123_l (pow k (pow k a4 r41) (pow2 l))) (pow k a4 r42); (==) { lemma_pow_distr_mul k acc_123_l a4 r41 r42 (pow2 l) } k.mul (pow k a4 (r41 * pow2 l + r42)) acc_123_l; (==) { lemma_b_div_pow2ki bBits b4 l i } k.mul res_a4 acc_123_l; }; calc (==) { k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32); (==) { } k.mul (k.mul res_a4 (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l))) (pow k a3 r32); (==) {k.lemma_mul_assoc res_a4 (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l)) (pow k a3 r32)} k.mul res_a4 (k.mul (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l)) (pow k a3 r32)); (==) { lemma_pow_mul_base k acc_12 (pow k a3 r31) (pow2 l) } k.mul res_a4 (k.mul (k.mul acc_12_l (pow k (pow k a3 r31) (pow2 l))) (pow k a3 r32)); (==) { lemma_pow_distr_mul k acc_12_l a3 r31 r32 (pow2 l) } k.mul res_a4 (k.mul (pow k a3 (r31 * pow2 l + r32)) acc_12_l); (==) { lemma_b_div_pow2ki bBits b3 l i } k.mul res_a4 (k.mul res_a3 acc_12_l); (==) { k.lemma_mul_assoc res_a4 res_a3 acc_12_l; k.lemma_mul_comm res_a4 res_a3 } k.mul (k.mul res_a3 res_a4) acc_12_l; }; let res_a234 = k.mul (k.mul res_a2 res_a3) res_a4 in let res_a34 = k.mul res_a3 res_a4 in calc (==) { k.mul (k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32)) (pow k a2 r22); (==) { } k.mul (k.mul res_a34 (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l))) (pow k a2 r22); (==) { lemma_mul_assoc res_a34 (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l)) (pow k a2 r22) } k.mul res_a34 (k.mul (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l)) (pow k a2 r22)); (==) { lemma_pow_mul_base k acc_1 (pow k a2 r21) (pow2 l) } k.mul res_a34 (k.mul (k.mul acc_1_l (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22)); (==) { lemma_pow_distr_mul k acc_1_l a2 r21 r22 (pow2 l) } k.mul res_a34 (k.mul (pow k a2 (r21 * pow2 l + r22)) acc_1_l); (==) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a34 (k.mul res_a2 acc_1_l); (==) { k.lemma_mul_assoc res_a34 res_a2 acc_1_l; k.lemma_mul_comm res_a34 res_a2 } k.mul (k.mul res_a2 res_a34) acc_1_l; (==) { k.lemma_mul_assoc res_a2 res_a3 res_a4 } k.mul res_a234 acc_1_l; }; calc (==) { k.mul (k.mul (k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32)) (pow k a2 r22)) (pow k a1 r12); (==) { } k.mul (k.mul res_a234 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); (==) { lemma_pow_distr_mul k res_a234 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a234; (==) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 (k.mul (k.mul res_a2 res_a3) res_a4); (==) { lemma_mul_assoc4 k res_a1 res_a2 res_a3 res_a4 } k.mul (k.mul (k.mul res_a1 res_a2) res_a3) res_a4; } val exp_four_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (mul (mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) (pow k a3 (b_acc l bBits b3 0))) (pow k a4 (b_acc l bBits b4 0)) in let acc = Loops.repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in acc == mul (mul (mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i))) let rec exp_four_fw_lemma_loop #t k a1 bBits b1 a2 b2 a3 b3 a4 b4 l i = let acc0 = mul (mul (mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) (pow k a3 (b_acc l bBits b3 0))) (pow k a4 (b_acc l bBits b4 0)) in let acc = Loops.repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 else begin Loops.unfold_repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in exp_four_fw_lemma_loop k a1 bBits b1 a2 b2 a3 b3 a4 b4 l (i - 1); exp_four_fw_lemma_step k a1 bBits b1 a2 b2 a3 b3 a4 b4 l i acc1; () end val exp_four_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_four_fw_acc0 k a1 bBits b1 a2 b2 a3 b3 a4 b4 l in let b1_rem = b_acc l bBits b1 0 in let b2_rem = b_acc l bBits b2 0 in let b3_rem = b_acc l bBits b3 0 in let b4_rem = b_acc l bBits b4 0 in acc0 == mul (mul (pow k a1 b1_rem) (pow k a2 b2_rem)) (mul (pow k a3 b3_rem) (pow k a4 b4_rem)))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_four_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_four_fw_acc0 k a1 bBits b1 a2 b2 a3 b3 a4 b4 l in let b1_rem = b_acc l bBits b1 0 in let b2_rem = b_acc l bBits b2 0 in let b3_rem = b_acc l bBits b3 0 in let b4_rem = b_acc l bBits b4 0 in acc0 == mul (mul (pow k a1 b1_rem) (pow k a2 b2_rem)) (mul (pow k a3 b3_rem) (pow k a4 b4_rem)))
[]
Lib.Exponentiation.exp_four_fw_acc0_lemma
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> a3: t -> b3: Prims.nat{b3 < Prims.pow2 bBits} -> a4: t -> b4: Prims.nat{b4 < Prims.pow2 bBits} -> l: Prims.pos -> FStar.Pervasives.Lemma (ensures (let acc0 = (match bBits % l = 0 with | true -> Lib.Exponentiation.Definition.one | _ -> Lib.Exponentiation.exp_four_fw_acc0 k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) <: t in let b1_rem = Lib.Exponentiation.b_acc l bBits b1 0 in let b2_rem = Lib.Exponentiation.b_acc l bBits b2 0 in let b3_rem = Lib.Exponentiation.b_acc l bBits b3 0 in let b4_rem = Lib.Exponentiation.b_acc l bBits b4 0 in acc0 == Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.pow k a1 b1_rem) (Lib.Exponentiation.Definition.pow k a2 b2_rem)) (Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.pow k a3 b3_rem) (Lib.Exponentiation.Definition.pow k a4 b4_rem))))
{ "end_col": 42, "end_line": 755, "start_col": 65, "start_line": 718 }
FStar.Pervasives.Lemma
val exp_four_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (mul (mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) (pow k a3 (b_acc l bBits b3 0))) (pow k a4 (b_acc l bBits b4 0)) in let acc = Loops.repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in acc == mul (mul (mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i)))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec exp_four_fw_lemma_loop #t k a1 bBits b1 a2 b2 a3 b3 a4 b4 l i = let acc0 = mul (mul (mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) (pow k a3 (b_acc l bBits b3 0))) (pow k a4 (b_acc l bBits b4 0)) in let acc = Loops.repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 else begin Loops.unfold_repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in exp_four_fw_lemma_loop k a1 bBits b1 a2 b2 a3 b3 a4 b4 l (i - 1); exp_four_fw_lemma_step k a1 bBits b1 a2 b2 a3 b3 a4 b4 l i acc1; () end
val exp_four_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (mul (mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) (pow k a3 (b_acc l bBits b3 0))) (pow k a4 (b_acc l bBits b4 0)) in let acc = Loops.repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in acc == mul (mul (mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i))) let rec exp_four_fw_lemma_loop #t k a1 bBits b1 a2 b2 a3 b3 a4 b4 l i =
false
null
true
let acc0 = mul (mul (mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) (pow k a3 (b_acc l bBits b3 0))) (pow k a4 (b_acc l bBits b4 0)) in let acc = Loops.repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 else (Loops.unfold_repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in exp_four_fw_lemma_loop k a1 bBits b1 a2 b2 a3 b3 a4 b4 l (i - 1); exp_four_fw_lemma_step k a1 bBits b1 a2 b2 a3 b3 a4 b4 l i acc1; ())
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Prims.op_Equality", "Prims.int", "Lib.LoopCombinators.eq_repeati0", "Lib.Exponentiation.exp_four_fw_f", "Prims.bool", "Prims.unit", "Lib.Exponentiation.exp_four_fw_lemma_step", "Lib.Exponentiation.exp_four_fw_lemma_loop", "Prims.op_Subtraction", "Lib.LoopCombinators.repeati", "Lib.LoopCombinators.unfold_repeati", "Lib.Exponentiation.Definition.mul", "Lib.Exponentiation.Definition.pow", "Lib.Exponentiation.b_acc" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end let exp_mont_ladder_swap_lemma #t k a bBits b = exp_mont_ladder_swap_lemma_loop #t k a bBits b 0 bBits //------------------------------ val exp_pow2_loop_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> i:nat{i <= b} -> Lemma (Loops.repeat i (sqr k) a == pow k a (pow2 i)) let rec exp_pow2_loop_lemma #t k a b i = if i = 0 then begin Loops.eq_repeat0 (sqr k) a; assert_norm (pow2 0 = 1); lemma_pow1 k a end else begin Loops.unfold_repeat b (sqr k) a (i - 1); exp_pow2_loop_lemma k a b (i - 1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); () end let exp_pow2_lemma #t k a b = exp_pow2_loop_lemma k a b b // Fixed-window method //--------------------- val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i)) let exp_fw_lemma_step #t k a bBits b l i acc1 = let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc (==) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); (==) { } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); (==) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); (==) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); (==) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); } val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i)) let rec exp_fw_lemma_loop #t k a bBits b l i = let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_fw_f k a bBits b l) acc0 else begin Loops.unfold_repeati i (exp_fw_f k a bBits b l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_fw_f k a bBits b l) acc0 in assert (acc == exp_fw_f k a bBits b l (i - 1) acc1); exp_fw_lemma_loop k a bBits b l (i - 1); exp_fw_lemma_step k a bBits b l i acc1; () end val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_lemma #t k a bBits b l = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in let acc = pow k a bits_c in assert (bits_c == b / pow2 (bBits / l * l) % pow2 l); Math.Lemmas.lemma_div_lt_nat b bBits (bBits / l * l); assert (b / pow2 (bBits / l * l) < pow2 (bBits % l)); Math.Lemmas.pow2_lt_compat l (bBits % l); Math.Lemmas.small_mod (b / pow2 (bBits / l * l)) (pow2 l); assert (bits_c == b / pow2 (bBits / l * l)); assert (acc == pow k a (b / pow2 (bBits / l * l))); () val exp_fw_acc0_aux_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in acc0 == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_aux_lemma #t k a bBits b l = if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b (pow2 bBits); assert (b / pow2 (bBits / l * l) == 0); lemma_pow0 k a; assert (acc == pow k a (b / pow2 (bBits / l * l))); () end else exp_fw_acc0_lemma #t k a bBits b l let exp_fw_lemma #t k a bBits b l = let b_rem = b_acc l bBits b 0 in let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in exp_fw_acc0_aux_lemma k a bBits b l; assert (acc0 == pow k a b_rem); let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in exp_fw_lemma_loop k a bBits b l (bBits / l); assert (res == pow k a (b_acc l bBits b (bBits / l))); Math.Lemmas.euclidean_division_definition bBits l; assert (res == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- val lemma_pow_distr_mul: #t:Type -> k:comm_monoid t -> x:t -> a:t -> r1:nat -> r2:nat -> r3:nat -> Lemma (k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2) == k.mul (pow k a (r1 * r3 + r2)) x) let lemma_pow_distr_mul #t k x a r1 r2 r3 = calc (==) { k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2); (==) { lemma_pow_mul k a r1 r3 } k.mul (k.mul x (pow k a (r1 * r3))) (pow k a r2); (==) { k.lemma_mul_assoc x (pow k a (r1 * r3)) (pow k a r2) } k.mul x (k.mul (pow k a (r1 * r3)) (pow k a r2)); (==) { lemma_pow_add k a (r1 * r3) r2 } k.mul x (pow k a (r1 * r3 + r2)); (==) { k.lemma_mul_comm x (pow k a (r1 * r3 + r2)) } k.mul (pow k a (r1 * r3 + r2)) x; } val exp_double_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (ensures exp_double_fw_f k a1 bBits b1 a2 b2 l (i - 1) acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let exp_double_fw_lemma_step #t k a1 bBits b1 a2 b2 l i acc = let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in calc (==) { k.mul acc1 (pow k a2 r22); (==) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a2 r22); (==) { } k.mul (pow k (k.mul (pow k a1 r11) (pow k a2 r21)) (pow2 l)) (pow k a2 r22); (==) { lemma_pow_mul_base k (pow k a1 r11) (pow k a2 r21) (pow2 l) } k.mul (k.mul (pow k (pow k a1 r11) (pow2 l)) (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22); (==) { lemma_pow_distr_mul k (pow k (pow k a1 r11) (pow2 l)) a2 r21 r22 (pow2 l) } k.mul (pow k a2 (r21 * pow2 l + r22)) (pow k (pow k a1 r11) (pow2 l)); (==) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a2 (pow k (pow k a1 r11) (pow2 l)); }; calc (==) { k.mul (k.mul acc1 (pow k a2 r22)) (pow k a1 r12); (==) { } k.mul (k.mul res_a2 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); (==) { lemma_pow_distr_mul k res_a2 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a2; (==) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 res_a2; } val exp_double_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let rec exp_double_fw_lemma_loop #t k a1 bBits b1 a2 b2 l i = let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 else begin Loops.unfold_repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in exp_double_fw_lemma_loop k a1 bBits b1 a2 b2 l (i - 1); exp_double_fw_lemma_step k a1 bBits b1 a2 b2 l i acc1; () end val exp_double_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in acc0 == mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) let exp_double_fw_acc0_lemma #t k a1 bBits b1 a2 b2 l = let bk = bBits - bBits % l in if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b1 (pow2 bBits); assert (b1 / pow2 (bBits / l * l) == 0); assert (b2 / pow2 (bBits / l * l) == 0); lemma_pow0 k a1; lemma_pow0 k a2; lemma_one k.one; assert (acc == mul (pow k a1 (b1 / pow2 bk)) (pow k a2 (b2 / pow2 bk))); () end else begin exp_fw_acc0_lemma #t k a1 bBits b1 l; exp_fw_acc0_lemma #t k a2 bBits b2 l end let exp_double_fw_lemma #t k a1 bBits b1 a2 b2 l = let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in exp_double_fw_acc0_lemma #t k a1 bBits b1 a2 b2 l; assert (acc0 == mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))); let res = Loops.repeati (bBits / l) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in exp_double_fw_lemma_loop k a1 bBits b1 a2 b2 l (bBits / l); Math.Lemmas.euclidean_division_definition bBits l; assert_norm (pow2 0 = 1) //------------------------- val lemma_mul_assoc4: #t:Type -> k:comm_monoid t -> a1:t -> a2:t -> a3:t -> a4:t -> Lemma (k.mul a1 (k.mul (k.mul a2 a3) a4) == k.mul (k.mul (k.mul a1 a2) a3) a4) let lemma_mul_assoc4 #t k a1 a2 a3 a4 = calc (==) { k.mul a1 (k.mul (k.mul a2 a3) a4); (==) { k.lemma_mul_assoc a1 (k.mul a2 a3) a4 } k.mul (k.mul a1 (k.mul a2 a3)) a4; (==) { k.lemma_mul_assoc a1 a2 a3 } k.mul (k.mul (k.mul a1 a2) a3) a4; } val exp_four_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (pow k a3 (b_acc l bBits b3 (i - 1)))) (pow k a4 (b_acc l bBits b4 (i - 1)))) (ensures exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l (i - 1) acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i))) let exp_four_fw_lemma_step #t k a1 bBits b1 a2 b2 a3 b3 a4 b4 l i acc = let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in let r31 = b_acc l bBits b3 (i - 1) in let r32 = b_acc l bBits b3 i % pow2 l in let r41 = b_acc l bBits b4 (i - 1) in let r42 = b_acc l bBits b4 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in let res_a3 = pow k a3 (b_acc l bBits b3 i) in let res_a4 = pow k a4 (b_acc l bBits b4 i) in let acc_1 = pow k a1 r11 in let acc_1_l = pow k acc_1 (pow2 l) in let acc_12 = k.mul acc_1 (pow k a2 r21) in let acc_12_l = pow k acc_12 (pow2 l) in let acc_123 = k.mul acc_12 (pow k a3 r31) in let acc_123_l = pow k acc_123 (pow2 l) in calc (==) { k.mul acc1 (pow k a4 r42); (==) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a4 r42); (==) { } k.mul (pow k (k.mul acc_123 (pow k a4 r41)) (pow2 l)) (pow k a4 r42); (==) { lemma_pow_mul_base k acc_123 (pow k a4 r41) (pow2 l) } k.mul (k.mul acc_123_l (pow k (pow k a4 r41) (pow2 l))) (pow k a4 r42); (==) { lemma_pow_distr_mul k acc_123_l a4 r41 r42 (pow2 l) } k.mul (pow k a4 (r41 * pow2 l + r42)) acc_123_l; (==) { lemma_b_div_pow2ki bBits b4 l i } k.mul res_a4 acc_123_l; }; calc (==) { k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32); (==) { } k.mul (k.mul res_a4 (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l))) (pow k a3 r32); (==) {k.lemma_mul_assoc res_a4 (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l)) (pow k a3 r32)} k.mul res_a4 (k.mul (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l)) (pow k a3 r32)); (==) { lemma_pow_mul_base k acc_12 (pow k a3 r31) (pow2 l) } k.mul res_a4 (k.mul (k.mul acc_12_l (pow k (pow k a3 r31) (pow2 l))) (pow k a3 r32)); (==) { lemma_pow_distr_mul k acc_12_l a3 r31 r32 (pow2 l) } k.mul res_a4 (k.mul (pow k a3 (r31 * pow2 l + r32)) acc_12_l); (==) { lemma_b_div_pow2ki bBits b3 l i } k.mul res_a4 (k.mul res_a3 acc_12_l); (==) { k.lemma_mul_assoc res_a4 res_a3 acc_12_l; k.lemma_mul_comm res_a4 res_a3 } k.mul (k.mul res_a3 res_a4) acc_12_l; }; let res_a234 = k.mul (k.mul res_a2 res_a3) res_a4 in let res_a34 = k.mul res_a3 res_a4 in calc (==) { k.mul (k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32)) (pow k a2 r22); (==) { } k.mul (k.mul res_a34 (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l))) (pow k a2 r22); (==) { lemma_mul_assoc res_a34 (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l)) (pow k a2 r22) } k.mul res_a34 (k.mul (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l)) (pow k a2 r22)); (==) { lemma_pow_mul_base k acc_1 (pow k a2 r21) (pow2 l) } k.mul res_a34 (k.mul (k.mul acc_1_l (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22)); (==) { lemma_pow_distr_mul k acc_1_l a2 r21 r22 (pow2 l) } k.mul res_a34 (k.mul (pow k a2 (r21 * pow2 l + r22)) acc_1_l); (==) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a34 (k.mul res_a2 acc_1_l); (==) { k.lemma_mul_assoc res_a34 res_a2 acc_1_l; k.lemma_mul_comm res_a34 res_a2 } k.mul (k.mul res_a2 res_a34) acc_1_l; (==) { k.lemma_mul_assoc res_a2 res_a3 res_a4 } k.mul res_a234 acc_1_l; }; calc (==) { k.mul (k.mul (k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32)) (pow k a2 r22)) (pow k a1 r12); (==) { } k.mul (k.mul res_a234 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); (==) { lemma_pow_distr_mul k res_a234 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a234; (==) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 (k.mul (k.mul res_a2 res_a3) res_a4); (==) { lemma_mul_assoc4 k res_a1 res_a2 res_a3 res_a4 } k.mul (k.mul (k.mul res_a1 res_a2) res_a3) res_a4; } val exp_four_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (mul (mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) (pow k a3 (b_acc l bBits b3 0))) (pow k a4 (b_acc l bBits b4 0)) in let acc = Loops.repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in acc == mul (mul (mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i)))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_four_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (mul (mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) (pow k a3 (b_acc l bBits b3 0))) (pow k a4 (b_acc l bBits b4 0)) in let acc = Loops.repeati i (exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in acc == mul (mul (mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i)))
[ "recursion" ]
Lib.Exponentiation.exp_four_fw_lemma_loop
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> a3: t -> b3: Prims.nat{b3 < Prims.pow2 bBits} -> a4: t -> b4: Prims.nat{b4 < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i <= bBits / l} -> FStar.Pervasives.Lemma (ensures (let acc0 = Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.pow k a1 (Lib.Exponentiation.b_acc l bBits b1 0)) (Lib.Exponentiation.Definition.pow k a2 (Lib.Exponentiation.b_acc l bBits b2 0)) ) (Lib.Exponentiation.Definition.pow k a3 (Lib.Exponentiation.b_acc l bBits b3 0))) (Lib.Exponentiation.Definition.pow k a4 (Lib.Exponentiation.b_acc l bBits b4 0)) in let acc = Lib.LoopCombinators.repeati i (Lib.Exponentiation.exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l) acc0 in acc == Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.pow k a1 (Lib.Exponentiation.b_acc l bBits b1 i)) (Lib.Exponentiation.Definition.pow k a2 (Lib.Exponentiation.b_acc l bBits b2 i))) (Lib.Exponentiation.Definition.pow k a3 (Lib.Exponentiation.b_acc l bBits b3 i))) (Lib.Exponentiation.Definition.pow k a4 (Lib.Exponentiation.b_acc l bBits b4 i))))
{ "end_col": 10, "end_line": 697, "start_col": 71, "start_line": 681 }
FStar.Pervasives.Lemma
val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; }
val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i =
false
null
true
let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc ( == ) { b / pow2 (bk - k * i); ( == ) { Math.Lemmas.euclidean_division_definition c (pow2 k) } (c / pow2 k) * pow2 k + c % pow2 k; ( == ) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } (b / (pow2 (bk - k * i) * pow2 k)) * pow2 k + c % pow2 k; ( == ) { Math.Lemmas.pow2_plus (bk - k * i) k } (b / pow2 (bk - k * i + k)) * pow2 k + c % pow2 k; ( == ) { Math.Lemmas.distributivity_sub_right k i 1 } (b / pow2 (bk - k * (i - 1))) * pow2 k + c % pow2 k; }
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_LessThanOrEqual", "Prims.op_Division", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Prims.op_Addition", "Prims.op_Modulus", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.euclidean_division_definition", "Prims.squash", "FStar.Math.Lemmas.division_multiplication_lemma", "FStar.Math.Lemmas.pow2_plus", "FStar.Math.Lemmas.distributivity_sub_right" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} ->
false
false
Lib.Exponentiation.fst
{ "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" }
null
val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i)
[]
Lib.Exponentiation.lemma_b_div_pow2ki
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> k: Prims.pos -> i: Prims.pos{i <= bBits / k} -> FStar.Pervasives.Lemma (ensures Lib.Exponentiation.b_acc k bBits b (i - 1) * Prims.pow2 k + Lib.Exponentiation.b_acc k bBits b i % Prims.pow2 k == Lib.Exponentiation.b_acc k bBits b i)
{ "end_col": 5, "end_line": 40, "start_col": 36, "start_line": 27 }
FStar.Pervasives.Lemma
val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_fw_lemma_step #t k a bBits b l i acc1 = let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc (==) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); (==) { } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); (==) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); (==) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); (==) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); }
val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i)) let exp_fw_lemma_step #t k a bBits b l i acc1 =
false
null
true
let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc ( == ) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); ( == ) { () } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); ( == ) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); ( == ) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); ( == ) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); }
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_LessThanOrEqual", "Prims.op_Division", "FStar.Calc.calc_finish", "Prims.eq2", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__mul", "Lib.Exponentiation.Definition.pow", "Lib.Exponentiation.b_acc", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Addition", "FStar.Mul.op_Star", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Lib.Exponentiation.Definition.lemma_pow_mul", "Lib.Exponentiation.Definition.lemma_pow_add", "Lib.Exponentiation.lemma_b_div_pow2ki", "Prims._assert", "FStar.Math.Lemmas.distributivity_sub_right", "Prims.int", "Prims.op_Modulus", "Prims.op_Subtraction", "Lib.Exponentiation.exp_pow2_lemma", "Lib.Exponentiation.exp_fw_f" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end let exp_mont_ladder_swap_lemma #t k a bBits b = exp_mont_ladder_swap_lemma_loop #t k a bBits b 0 bBits //------------------------------ val exp_pow2_loop_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> i:nat{i <= b} -> Lemma (Loops.repeat i (sqr k) a == pow k a (pow2 i)) let rec exp_pow2_loop_lemma #t k a b i = if i = 0 then begin Loops.eq_repeat0 (sqr k) a; assert_norm (pow2 0 = 1); lemma_pow1 k a end else begin Loops.unfold_repeat b (sqr k) a (i - 1); exp_pow2_loop_lemma k a b (i - 1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); () end let exp_pow2_lemma #t k a b = exp_pow2_loop_lemma k a b b // Fixed-window method //--------------------- val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i))
[]
Lib.Exponentiation.exp_fw_lemma_step
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.pos{i <= bBits / l} -> acc1: t -> FStar.Pervasives.Lemma (requires acc1 == Lib.Exponentiation.Definition.pow k a (Lib.Exponentiation.b_acc l bBits b (i - 1))) (ensures Lib.Exponentiation.exp_fw_f k a bBits b l (i - 1) acc1 == Lib.Exponentiation.Definition.pow k a (Lib.Exponentiation.b_acc l bBits b i))
{ "end_col": 3, "end_line": 328, "start_col": 47, "start_line": 309 }
FStar.Pervasives.Lemma
val exp_double_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (ensures exp_double_fw_f k a1 bBits b1 a2 b2 l (i - 1) acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i)))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_double_fw_lemma_step #t k a1 bBits b1 a2 b2 l i acc = let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in calc (==) { k.mul acc1 (pow k a2 r22); (==) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a2 r22); (==) { } k.mul (pow k (k.mul (pow k a1 r11) (pow k a2 r21)) (pow2 l)) (pow k a2 r22); (==) { lemma_pow_mul_base k (pow k a1 r11) (pow k a2 r21) (pow2 l) } k.mul (k.mul (pow k (pow k a1 r11) (pow2 l)) (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22); (==) { lemma_pow_distr_mul k (pow k (pow k a1 r11) (pow2 l)) a2 r21 r22 (pow2 l) } k.mul (pow k a2 (r21 * pow2 l + r22)) (pow k (pow k a1 r11) (pow2 l)); (==) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a2 (pow k (pow k a1 r11) (pow2 l)); }; calc (==) { k.mul (k.mul acc1 (pow k a2 r22)) (pow k a1 r12); (==) { } k.mul (k.mul res_a2 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); (==) { lemma_pow_distr_mul k res_a2 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a2; (==) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 res_a2; }
val exp_double_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (ensures exp_double_fw_f k a1 bBits b1 a2 b2 l (i - 1) acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let exp_double_fw_lemma_step #t k a1 bBits b1 a2 b2 l i acc =
false
null
true
let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in calc ( == ) { k.mul acc1 (pow k a2 r22); ( == ) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a2 r22); ( == ) { () } k.mul (pow k (k.mul (pow k a1 r11) (pow k a2 r21)) (pow2 l)) (pow k a2 r22); ( == ) { lemma_pow_mul_base k (pow k a1 r11) (pow k a2 r21) (pow2 l) } k.mul (k.mul (pow k (pow k a1 r11) (pow2 l)) (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22); ( == ) { lemma_pow_distr_mul k (pow k (pow k a1 r11) (pow2 l)) a2 r21 r22 (pow2 l) } k.mul (pow k a2 (r21 * pow2 l + r22)) (pow k (pow k a1 r11) (pow2 l)); ( == ) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a2 (pow k (pow k a1 r11) (pow2 l)); }; calc ( == ) { k.mul (k.mul acc1 (pow k a2 r22)) (pow k a1 r12); ( == ) { () } k.mul (k.mul res_a2 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); ( == ) { lemma_pow_distr_mul k res_a2 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a2; ( == ) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 res_a2; }
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_LessThanOrEqual", "Prims.op_Division", "FStar.Calc.calc_finish", "Prims.eq2", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__mul", "Lib.Exponentiation.Definition.pow", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Addition", "FStar.Mul.op_Star", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Lib.Exponentiation.lemma_pow_distr_mul", "Lib.Exponentiation.lemma_b_div_pow2ki", "Lib.Exponentiation.exp_pow2_lemma", "Lib.Exponentiation.Definition.lemma_pow_mul_base", "Lib.Exponentiation.b_acc", "FStar.Math.Lemmas.distributivity_sub_right", "Prims.int", "Prims.op_Modulus", "Prims.op_Subtraction", "Lib.Exponentiation.exp_pow2" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end let exp_mont_ladder_swap_lemma #t k a bBits b = exp_mont_ladder_swap_lemma_loop #t k a bBits b 0 bBits //------------------------------ val exp_pow2_loop_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> i:nat{i <= b} -> Lemma (Loops.repeat i (sqr k) a == pow k a (pow2 i)) let rec exp_pow2_loop_lemma #t k a b i = if i = 0 then begin Loops.eq_repeat0 (sqr k) a; assert_norm (pow2 0 = 1); lemma_pow1 k a end else begin Loops.unfold_repeat b (sqr k) a (i - 1); exp_pow2_loop_lemma k a b (i - 1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); () end let exp_pow2_lemma #t k a b = exp_pow2_loop_lemma k a b b // Fixed-window method //--------------------- val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i)) let exp_fw_lemma_step #t k a bBits b l i acc1 = let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc (==) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); (==) { } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); (==) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); (==) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); (==) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); } val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i)) let rec exp_fw_lemma_loop #t k a bBits b l i = let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_fw_f k a bBits b l) acc0 else begin Loops.unfold_repeati i (exp_fw_f k a bBits b l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_fw_f k a bBits b l) acc0 in assert (acc == exp_fw_f k a bBits b l (i - 1) acc1); exp_fw_lemma_loop k a bBits b l (i - 1); exp_fw_lemma_step k a bBits b l i acc1; () end val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_lemma #t k a bBits b l = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in let acc = pow k a bits_c in assert (bits_c == b / pow2 (bBits / l * l) % pow2 l); Math.Lemmas.lemma_div_lt_nat b bBits (bBits / l * l); assert (b / pow2 (bBits / l * l) < pow2 (bBits % l)); Math.Lemmas.pow2_lt_compat l (bBits % l); Math.Lemmas.small_mod (b / pow2 (bBits / l * l)) (pow2 l); assert (bits_c == b / pow2 (bBits / l * l)); assert (acc == pow k a (b / pow2 (bBits / l * l))); () val exp_fw_acc0_aux_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in acc0 == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_aux_lemma #t k a bBits b l = if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b (pow2 bBits); assert (b / pow2 (bBits / l * l) == 0); lemma_pow0 k a; assert (acc == pow k a (b / pow2 (bBits / l * l))); () end else exp_fw_acc0_lemma #t k a bBits b l let exp_fw_lemma #t k a bBits b l = let b_rem = b_acc l bBits b 0 in let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in exp_fw_acc0_aux_lemma k a bBits b l; assert (acc0 == pow k a b_rem); let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in exp_fw_lemma_loop k a bBits b l (bBits / l); assert (res == pow k a (b_acc l bBits b (bBits / l))); Math.Lemmas.euclidean_division_definition bBits l; assert (res == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- val lemma_pow_distr_mul: #t:Type -> k:comm_monoid t -> x:t -> a:t -> r1:nat -> r2:nat -> r3:nat -> Lemma (k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2) == k.mul (pow k a (r1 * r3 + r2)) x) let lemma_pow_distr_mul #t k x a r1 r2 r3 = calc (==) { k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2); (==) { lemma_pow_mul k a r1 r3 } k.mul (k.mul x (pow k a (r1 * r3))) (pow k a r2); (==) { k.lemma_mul_assoc x (pow k a (r1 * r3)) (pow k a r2) } k.mul x (k.mul (pow k a (r1 * r3)) (pow k a r2)); (==) { lemma_pow_add k a (r1 * r3) r2 } k.mul x (pow k a (r1 * r3 + r2)); (==) { k.lemma_mul_comm x (pow k a (r1 * r3 + r2)) } k.mul (pow k a (r1 * r3 + r2)) x; } val exp_double_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (ensures exp_double_fw_f k a1 bBits b1 a2 b2 l (i - 1) acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i)))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_double_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (ensures exp_double_fw_f k a1 bBits b1 a2 b2 l (i - 1) acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i)))
[]
Lib.Exponentiation.exp_double_fw_lemma_step
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.pos{i <= bBits / l} -> acc: t -> FStar.Pervasives.Lemma (requires acc == Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.pow k a1 (Lib.Exponentiation.b_acc l bBits b1 (i - 1))) (Lib.Exponentiation.Definition.pow k a2 (Lib.Exponentiation.b_acc l bBits b2 (i - 1)))) (ensures Lib.Exponentiation.exp_double_fw_f k a1 bBits b1 a2 b2 l (i - 1) acc == Lib.Exponentiation.Definition.mul (Lib.Exponentiation.Definition.pow k a1 (Lib.Exponentiation.b_acc l bBits b1 i)) (Lib.Exponentiation.Definition.pow k a2 (Lib.Exponentiation.b_acc l bBits b2 i)))
{ "end_col": 3, "end_line": 470, "start_col": 61, "start_line": 437 }
FStar.Pervasives.Lemma
val exp_four_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (pow k a3 (b_acc l bBits b3 (i - 1)))) (pow k a4 (b_acc l bBits b4 (i - 1)))) (ensures exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l (i - 1) acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i)))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation.Definition", "short_module": null }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_four_fw_lemma_step #t k a1 bBits b1 a2 b2 a3 b3 a4 b4 l i acc = let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in let r31 = b_acc l bBits b3 (i - 1) in let r32 = b_acc l bBits b3 i % pow2 l in let r41 = b_acc l bBits b4 (i - 1) in let r42 = b_acc l bBits b4 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in let res_a3 = pow k a3 (b_acc l bBits b3 i) in let res_a4 = pow k a4 (b_acc l bBits b4 i) in let acc_1 = pow k a1 r11 in let acc_1_l = pow k acc_1 (pow2 l) in let acc_12 = k.mul acc_1 (pow k a2 r21) in let acc_12_l = pow k acc_12 (pow2 l) in let acc_123 = k.mul acc_12 (pow k a3 r31) in let acc_123_l = pow k acc_123 (pow2 l) in calc (==) { k.mul acc1 (pow k a4 r42); (==) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a4 r42); (==) { } k.mul (pow k (k.mul acc_123 (pow k a4 r41)) (pow2 l)) (pow k a4 r42); (==) { lemma_pow_mul_base k acc_123 (pow k a4 r41) (pow2 l) } k.mul (k.mul acc_123_l (pow k (pow k a4 r41) (pow2 l))) (pow k a4 r42); (==) { lemma_pow_distr_mul k acc_123_l a4 r41 r42 (pow2 l) } k.mul (pow k a4 (r41 * pow2 l + r42)) acc_123_l; (==) { lemma_b_div_pow2ki bBits b4 l i } k.mul res_a4 acc_123_l; }; calc (==) { k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32); (==) { } k.mul (k.mul res_a4 (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l))) (pow k a3 r32); (==) {k.lemma_mul_assoc res_a4 (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l)) (pow k a3 r32)} k.mul res_a4 (k.mul (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l)) (pow k a3 r32)); (==) { lemma_pow_mul_base k acc_12 (pow k a3 r31) (pow2 l) } k.mul res_a4 (k.mul (k.mul acc_12_l (pow k (pow k a3 r31) (pow2 l))) (pow k a3 r32)); (==) { lemma_pow_distr_mul k acc_12_l a3 r31 r32 (pow2 l) } k.mul res_a4 (k.mul (pow k a3 (r31 * pow2 l + r32)) acc_12_l); (==) { lemma_b_div_pow2ki bBits b3 l i } k.mul res_a4 (k.mul res_a3 acc_12_l); (==) { k.lemma_mul_assoc res_a4 res_a3 acc_12_l; k.lemma_mul_comm res_a4 res_a3 } k.mul (k.mul res_a3 res_a4) acc_12_l; }; let res_a234 = k.mul (k.mul res_a2 res_a3) res_a4 in let res_a34 = k.mul res_a3 res_a4 in calc (==) { k.mul (k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32)) (pow k a2 r22); (==) { } k.mul (k.mul res_a34 (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l))) (pow k a2 r22); (==) { lemma_mul_assoc res_a34 (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l)) (pow k a2 r22) } k.mul res_a34 (k.mul (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l)) (pow k a2 r22)); (==) { lemma_pow_mul_base k acc_1 (pow k a2 r21) (pow2 l) } k.mul res_a34 (k.mul (k.mul acc_1_l (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22)); (==) { lemma_pow_distr_mul k acc_1_l a2 r21 r22 (pow2 l) } k.mul res_a34 (k.mul (pow k a2 (r21 * pow2 l + r22)) acc_1_l); (==) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a34 (k.mul res_a2 acc_1_l); (==) { k.lemma_mul_assoc res_a34 res_a2 acc_1_l; k.lemma_mul_comm res_a34 res_a2 } k.mul (k.mul res_a2 res_a34) acc_1_l; (==) { k.lemma_mul_assoc res_a2 res_a3 res_a4 } k.mul res_a234 acc_1_l; }; calc (==) { k.mul (k.mul (k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32)) (pow k a2 r22)) (pow k a1 r12); (==) { } k.mul (k.mul res_a234 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); (==) { lemma_pow_distr_mul k res_a234 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a234; (==) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 (k.mul (k.mul res_a2 res_a3) res_a4); (==) { lemma_mul_assoc4 k res_a1 res_a2 res_a3 res_a4 } k.mul (k.mul (k.mul res_a1 res_a2) res_a3) res_a4; }
val exp_four_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (pow k a3 (b_acc l bBits b3 (i - 1)))) (pow k a4 (b_acc l bBits b4 (i - 1)))) (ensures exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l (i - 1) acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i))) let exp_four_fw_lemma_step #t k a1 bBits b1 a2 b2 a3 b3 a4 b4 l i acc =
false
null
true
let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in let r31 = b_acc l bBits b3 (i - 1) in let r32 = b_acc l bBits b3 i % pow2 l in let r41 = b_acc l bBits b4 (i - 1) in let r42 = b_acc l bBits b4 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in let res_a3 = pow k a3 (b_acc l bBits b3 i) in let res_a4 = pow k a4 (b_acc l bBits b4 i) in let acc_1 = pow k a1 r11 in let acc_1_l = pow k acc_1 (pow2 l) in let acc_12 = k.mul acc_1 (pow k a2 r21) in let acc_12_l = pow k acc_12 (pow2 l) in let acc_123 = k.mul acc_12 (pow k a3 r31) in let acc_123_l = pow k acc_123 (pow2 l) in calc ( == ) { k.mul acc1 (pow k a4 r42); ( == ) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a4 r42); ( == ) { () } k.mul (pow k (k.mul acc_123 (pow k a4 r41)) (pow2 l)) (pow k a4 r42); ( == ) { lemma_pow_mul_base k acc_123 (pow k a4 r41) (pow2 l) } k.mul (k.mul acc_123_l (pow k (pow k a4 r41) (pow2 l))) (pow k a4 r42); ( == ) { lemma_pow_distr_mul k acc_123_l a4 r41 r42 (pow2 l) } k.mul (pow k a4 (r41 * pow2 l + r42)) acc_123_l; ( == ) { lemma_b_div_pow2ki bBits b4 l i } k.mul res_a4 acc_123_l; }; calc ( == ) { k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32); ( == ) { () } k.mul (k.mul res_a4 (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l))) (pow k a3 r32); ( == ) { k.lemma_mul_assoc res_a4 (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l)) (pow k a3 r32) } k.mul res_a4 (k.mul (pow k (k.mul acc_12 (pow k a3 r31)) (pow2 l)) (pow k a3 r32)); ( == ) { lemma_pow_mul_base k acc_12 (pow k a3 r31) (pow2 l) } k.mul res_a4 (k.mul (k.mul acc_12_l (pow k (pow k a3 r31) (pow2 l))) (pow k a3 r32)); ( == ) { lemma_pow_distr_mul k acc_12_l a3 r31 r32 (pow2 l) } k.mul res_a4 (k.mul (pow k a3 (r31 * pow2 l + r32)) acc_12_l); ( == ) { lemma_b_div_pow2ki bBits b3 l i } k.mul res_a4 (k.mul res_a3 acc_12_l); ( == ) { (k.lemma_mul_assoc res_a4 res_a3 acc_12_l; k.lemma_mul_comm res_a4 res_a3) } k.mul (k.mul res_a3 res_a4) acc_12_l; }; let res_a234 = k.mul (k.mul res_a2 res_a3) res_a4 in let res_a34 = k.mul res_a3 res_a4 in calc ( == ) { k.mul (k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32)) (pow k a2 r22); ( == ) { () } k.mul (k.mul res_a34 (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l))) (pow k a2 r22); ( == ) { lemma_mul_assoc res_a34 (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l)) (pow k a2 r22) } k.mul res_a34 (k.mul (pow k (k.mul acc_1 (pow k a2 r21)) (pow2 l)) (pow k a2 r22)); ( == ) { lemma_pow_mul_base k acc_1 (pow k a2 r21) (pow2 l) } k.mul res_a34 (k.mul (k.mul acc_1_l (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22)); ( == ) { lemma_pow_distr_mul k acc_1_l a2 r21 r22 (pow2 l) } k.mul res_a34 (k.mul (pow k a2 (r21 * pow2 l + r22)) acc_1_l); ( == ) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a34 (k.mul res_a2 acc_1_l); ( == ) { (k.lemma_mul_assoc res_a34 res_a2 acc_1_l; k.lemma_mul_comm res_a34 res_a2) } k.mul (k.mul res_a2 res_a34) acc_1_l; ( == ) { k.lemma_mul_assoc res_a2 res_a3 res_a4 } k.mul res_a234 acc_1_l; }; calc ( == ) { k.mul (k.mul (k.mul (k.mul acc1 (pow k a4 r42)) (pow k a3 r32)) (pow k a2 r22)) (pow k a1 r12); ( == ) { () } k.mul (k.mul res_a234 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); ( == ) { lemma_pow_distr_mul k res_a234 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a234; ( == ) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 (k.mul (k.mul res_a2 res_a3) res_a4); ( == ) { lemma_mul_assoc4 k res_a1 res_a2 res_a3 res_a4 } k.mul (k.mul (k.mul res_a1 res_a2) res_a3) res_a4; }
{ "checked_file": "Lib.Exponentiation.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.Exponentiation.fst" }
[ "lemma" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_LessThanOrEqual", "Prims.op_Division", "FStar.Calc.calc_finish", "Prims.eq2", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__mul", "Lib.Exponentiation.Definition.pow", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Addition", "FStar.Mul.op_Star", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Lib.Exponentiation.lemma_pow_distr_mul", "Lib.Exponentiation.lemma_b_div_pow2ki", "Lib.Exponentiation.lemma_mul_assoc4", "Lib.Exponentiation.Definition.lemma_mul_assoc", "Lib.Exponentiation.Definition.lemma_pow_mul_base", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__lemma_mul_comm", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__lemma_mul_assoc", "Lib.Exponentiation.exp_pow2_lemma", "Lib.Exponentiation.b_acc", "FStar.Math.Lemmas.distributivity_sub_right", "Prims.int", "Prims.op_Modulus", "Prims.op_Subtraction", "Lib.Exponentiation.exp_pow2" ]
[]
module Lib.Exponentiation open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_b_mod_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)) let lemma_b_mod_pow2i bBits b i = calc (==) { b % pow2 i; (==) { Math.Lemmas.euclidean_division_definition (b % pow2 i) (pow2 (i - 1)) } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 i % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_modulo_lemma_1 b (i - 1) i } b % pow2 i / pow2 (i - 1) * pow2 (i - 1) + b % pow2 (i - 1); (==) { Math.Lemmas.pow2_modulo_division_lemma_1 b (i - 1) i; assert_norm (pow2 1 = 2) } b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1); } let b_acc (l:pos) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i <= bBits / l}) : nat = b / pow2 (bBits - bBits % l - l * i) val lemma_b_div_pow2ki: bBits:nat -> b:nat{b < pow2 bBits} -> k:pos -> i:pos{i <= bBits / k} -> Lemma (b_acc k bBits b (i - 1) * pow2 k + b_acc k bBits b i % pow2 k == b_acc k bBits b i) let lemma_b_div_pow2ki bBits b k i = let bk = bBits - bBits % k in let c = b / pow2 (bk - k * i) in calc (==) { b / pow2 (bk - k * i); (==) { Math.Lemmas.euclidean_division_definition c (pow2 k) } c / pow2 k * pow2 k + c % pow2 k; (==) { Math.Lemmas.division_multiplication_lemma b (pow2 (bk - k * i)) (pow2 k) } b / (pow2 (bk - k * i) * pow2 k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.pow2_plus (bk - k * i) k } b / pow2 (bk - k * i + k) * pow2 k + c % pow2 k; (==) { Math.Lemmas.distributivity_sub_right k i 1 } b / pow2 (bk - k * (i - 1)) * pow2 k + c % pow2 k; } val lemma_b_div_pow2i: bBits:nat -> b:nat{b < pow2 bBits} -> i:pos{i <= bBits} -> Lemma (b / pow2 (bBits - i) == b / pow2 (bBits - i + 1) * 2 + b / pow2 (bBits - i) % 2) let lemma_b_div_pow2i bBits b i = assert_norm (pow2 1 = 2); lemma_b_div_pow2ki bBits b 1 i //------------------------------ val exp_rl_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> a:t -> Lemma (let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in acc == pow k a (b % pow2 i) /\ c == pow k a (pow2 i)) let rec exp_rl_lemma_loop #t k bBits b i a = let (acc, c) = Loops.repeati i (exp_rl_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_rl_f k bBits b) (one, a); assert_norm (pow2 0 = 1); lemma_pow0 k a; lemma_pow1 k a; () end else begin let (acc1, c1) = Loops.repeati (i - 1) (exp_rl_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_rl_f k bBits b) (one, a) (i - 1); exp_rl_lemma_loop #t k bBits b (i - 1) a; assert (acc1 == pow k a (b % pow2 (i - 1)) /\ c1 == pow k a (pow2 (i - 1))); //assert (c == k.mul c1 c1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); assert (c == pow k a (pow2 i)); lemma_b_mod_pow2i bBits b i; assert (b % pow2 i == b / pow2 (i - 1) % 2 * pow2 (i - 1) + b % pow2 (i - 1)); if (b / pow2 (i - 1) % 2 = 1) then begin //assert (acc == acc1 * a1); assert (acc == mul (pow k a (b % pow2 (i - 1))) (pow k a (pow2 (i - 1)))); lemma_pow_add k a (b % pow2 (i - 1)) (pow2 (i - 1)); assert (acc == pow k a (b % pow2 i)); () end else () end let exp_rl_lemma #t k a bBits b = let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in exp_rl_lemma_loop k bBits b bBits a; assert (acc == pow k a (b % pow2 bBits)); Math.Lemmas.small_mod b (pow2 bBits) //------------------------------ val exp_lr_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i < bBits} -> acc1:t -> Lemma (requires acc1 == pow k a (b / pow2 (bBits - i))) (ensures exp_lr_f k a bBits b i acc1 == pow k a (b / pow2 (bBits - i - 1))) let exp_lr_lemma_step #t k a bBits b i acc1 = let acc = exp_lr_f k a bBits b i acc1 in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul acc1 acc1 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then () else begin assert (acc == mul (pow k a (b / pow2 (bBits - i) * 2)) a); lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; () end val exp_lr_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let acc = Loops.repeati i (exp_lr_f k a bBits b) one in acc == pow k a (b / pow2 (bBits - i))) let rec exp_lr_lemma_loop #t k a bBits b i = let acc = Loops.repeati i (exp_lr_f k a bBits b) one in if i = 0 then begin Loops.eq_repeati0 i (exp_lr_f k a bBits b) one; lemma_pow0 k a; () end else begin let acc1 = Loops.repeati (i - 1) (exp_lr_f k a bBits b) one in Loops.unfold_repeati i (exp_lr_f k a bBits b) one (i - 1); //assert (acc == exp_lr_f k a bBits b (i - 1) acc1); exp_lr_lemma_loop k a bBits b (i - 1); //assert (acc1 == pow k a (b / pow2 (bBits - i + 1))); exp_lr_lemma_step #t k a bBits b (i - 1) acc1; //assert (acc == pow k a (b / pow2 (bBits - i))); () end let exp_lr_lemma #t k a bBits b = let acc = Loops.repeati bBits (exp_lr_f k a bBits b) one in exp_lr_lemma_loop #t k a bBits b bBits; assert (acc == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_lemma_step: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> r0:t -> r1:t -> i:nat{i < bBits} -> Lemma (requires r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) (ensures (let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in r1' == mul r0' a /\ r0' == pow k a (b / pow2 (bBits - i - 1)))) let exp_mont_ladder_lemma_step #t k bBits b a r0 r1 i = let (r0', r1') = exp_mont_ladder_f k bBits b i (r0, r1) in lemma_b_div_pow2i bBits b (i + 1); assert (b / pow2 (bBits - i - 1) == b / pow2 (bBits - i) * 2 + b / pow2 (bBits - i - 1) % 2); lemma_pow_add k a (b / pow2 (bBits - i)) (b / pow2 (bBits - i)); assert (mul r0 r0 == pow k a (b / pow2 (bBits - i) * 2)); if (b / pow2 (bBits - i - 1) % 2 = 0) then begin assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r0); assert (r1' == mul (mul r0 a) r0); lemma_mul_comm r0 a; lemma_mul_assoc a r0 r0; assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end else begin //assert (r0' == mul r0 r1); assert (r0' == mul r0 (mul r0 a)); lemma_mul_assoc r0 r0 a; lemma_pow1 k a; lemma_pow_add k a (b / pow2 (bBits - i) * 2) 1; assert (r0' == pow k a (b / pow2 (bBits - i - 1))); //assert (r1' == mul r1 r1); assert (r1' == mul (mul r0 a) (mul r0 a)); lemma_mul_comm r0 a; lemma_mul_assoc a r0 (mul r0 a); assert (r1' == mul a r0'); lemma_mul_comm a r0'; () end val exp_mont_ladder_lemma_loop: #t:Type -> k:comm_monoid t -> bBits:nat -> b:nat{b < pow2 bBits} -> a:t -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r1 == mul r0 a /\ r0 == pow k a (b / pow2 (bBits - i))) let rec exp_mont_ladder_lemma_loop #t k bBits b a i = let (r0, r1) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); Math.Lemmas.small_div b (pow2 bBits); lemma_pow0 k a; lemma_one a; lemma_mul_comm a one; //mul one r1 == r1 () end else begin let (r0', r1') = Loops.repeati (i - 1) (exp_mont_ladder_f k bBits b) (one, a) in Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_lemma_loop k bBits b a (i - 1); exp_mont_ladder_lemma_step #t k bBits b a r0' r1' (i - 1); () end let exp_mont_ladder_lemma # t k a bBits b = let (r0, r1) = Loops.repeati bBits (exp_mont_ladder_f k bBits b) (one, a) in exp_mont_ladder_lemma_loop #t k bBits b a bBits; assert_norm (pow2 0 = 1) //------------------------------ val exp_mont_ladder_swap2_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> i:nat{i <= bBits} -> Lemma (let (r0, r1) = Loops.repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (one, a) in r0 == r3 /\ r1 == r4) let rec exp_mont_ladder_swap2_lemma_loop #t k a bBits b i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap2_f k bBits b) (one, a); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (one, a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap2_f k bBits b) (one, a) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (one, a) (i - 1); exp_mont_ladder_swap2_lemma_loop k a bBits b (i - 1); () end let exp_mont_ladder_swap2_lemma #t k a bBits b = exp_mont_ladder_swap2_lemma_loop #t k a bBits b bBits val exp_mont_ladder_swap_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> sw0:nat{sw0 == b / pow2 bBits % 2} -> i:nat{i <= bBits} -> Lemma (let (r0, r1, sw) = Loops.repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) in let (r3, r4) = Loops.repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) in let bit = b / pow2 (bBits - i) % 2 in sw == bit /\ cswap bit r0 r1 == (r3, r4)) let rec exp_mont_ladder_swap_lemma_loop #t k a bBits b sw0 i = if i = 0 then begin Loops.eq_repeati0 i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0); Loops.eq_repeati0 i (exp_mont_ladder_f k bBits b) (cswap sw0 one a); () end else begin Loops.unfold_repeati i (exp_mont_ladder_swap_f k bBits b) (one, a, sw0) (i - 1); Loops.unfold_repeati i (exp_mont_ladder_f k bBits b) (cswap sw0 one a) (i - 1); exp_mont_ladder_swap_lemma_loop k a bBits b sw0 (i - 1); () end let exp_mont_ladder_swap_lemma #t k a bBits b = exp_mont_ladder_swap_lemma_loop #t k a bBits b 0 bBits //------------------------------ val exp_pow2_loop_lemma: #t:Type -> k:comm_monoid t -> a:t -> b:nat -> i:nat{i <= b} -> Lemma (Loops.repeat i (sqr k) a == pow k a (pow2 i)) let rec exp_pow2_loop_lemma #t k a b i = if i = 0 then begin Loops.eq_repeat0 (sqr k) a; assert_norm (pow2 0 = 1); lemma_pow1 k a end else begin Loops.unfold_repeat b (sqr k) a (i - 1); exp_pow2_loop_lemma k a b (i - 1); lemma_pow_add k a (pow2 (i - 1)) (pow2 (i - 1)); Math.Lemmas.pow2_double_sum (i - 1); () end let exp_pow2_lemma #t k a b = exp_pow2_loop_lemma k a b b // Fixed-window method //--------------------- val exp_fw_lemma_step: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc1:t -> Lemma (requires acc1 == pow k a (b_acc l bBits b (i - 1))) (ensures exp_fw_f k a bBits b l (i - 1) acc1 == pow k a (b_acc l bBits b i)) let exp_fw_lemma_step #t k a bBits b l i acc1 = let acc = exp_fw_f k a bBits b l (i - 1) acc1 in exp_pow2_lemma k acc1 l; let r1 = b_acc l bBits b (i - 1) in let r2 = b_acc l bBits b i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; assert (acc == k.mul (pow k acc1 (pow2 l)) (pow k a r2)); calc (==) { k.mul (pow k acc1 (pow2 l)) (pow k a r2); (==) { } k.mul (pow k (pow k a r1) (pow2 l)) (pow k a r2); (==) { lemma_pow_mul k a r1 (pow2 l) } k.mul (pow k a (r1 * pow2 l)) (pow k a r2); (==) { lemma_pow_add k a (r1 * pow2 l) r2 } pow k a (r1 * pow2 l + r2); (==) { lemma_b_div_pow2ki bBits b l i } pow k a (b_acc l bBits b i); } val exp_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in acc == pow k a (b_acc l bBits b i)) let rec exp_fw_lemma_loop #t k a bBits b l i = let acc0 = pow k a (b_acc l bBits b 0) in let acc = Loops.repeati i (exp_fw_f k a bBits b l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_fw_f k a bBits b l) acc0 else begin Loops.unfold_repeati i (exp_fw_f k a bBits b l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_fw_f k a bBits b l) acc0 in assert (acc == exp_fw_f k a bBits b l (i - 1) acc1); exp_fw_lemma_loop k a bBits b l (i - 1); exp_fw_lemma_step k a bBits b l i acc1; () end val exp_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos{bBits % l <> 0} -> Lemma (exp_fw_acc0 k a bBits b l == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_lemma #t k a bBits b l = let bits_c = get_ith_lbits bBits b (bBits / l * l) l in let acc = pow k a bits_c in assert (bits_c == b / pow2 (bBits / l * l) % pow2 l); Math.Lemmas.lemma_div_lt_nat b bBits (bBits / l * l); assert (b / pow2 (bBits / l * l) < pow2 (bBits % l)); Math.Lemmas.pow2_lt_compat l (bBits % l); Math.Lemmas.small_mod (b / pow2 (bBits / l * l)) (pow2 l); assert (bits_c == b / pow2 (bBits / l * l)); assert (acc == pow k a (b / pow2 (bBits / l * l))); () val exp_fw_acc0_aux_lemma: #t:Type -> k:comm_monoid t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in acc0 == pow k a (b_acc l bBits b 0)) let exp_fw_acc0_aux_lemma #t k a bBits b l = if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b (pow2 bBits); assert (b / pow2 (bBits / l * l) == 0); lemma_pow0 k a; assert (acc == pow k a (b / pow2 (bBits / l * l))); () end else exp_fw_acc0_lemma #t k a bBits b l let exp_fw_lemma #t k a bBits b l = let b_rem = b_acc l bBits b 0 in let acc0 = if bBits % l = 0 then one else exp_fw_acc0 k a bBits b l in exp_fw_acc0_aux_lemma k a bBits b l; assert (acc0 == pow k a b_rem); let res = Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 in exp_fw_lemma_loop k a bBits b l (bBits / l); assert (res == pow k a (b_acc l bBits b (bBits / l))); Math.Lemmas.euclidean_division_definition bBits l; assert (res == pow k a (b / pow2 0)); assert_norm (pow2 0 = 1) // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- val lemma_pow_distr_mul: #t:Type -> k:comm_monoid t -> x:t -> a:t -> r1:nat -> r2:nat -> r3:nat -> Lemma (k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2) == k.mul (pow k a (r1 * r3 + r2)) x) let lemma_pow_distr_mul #t k x a r1 r2 r3 = calc (==) { k.mul (k.mul x (pow k (pow k a r1) r3)) (pow k a r2); (==) { lemma_pow_mul k a r1 r3 } k.mul (k.mul x (pow k a (r1 * r3))) (pow k a r2); (==) { k.lemma_mul_assoc x (pow k a (r1 * r3)) (pow k a r2) } k.mul x (k.mul (pow k a (r1 * r3)) (pow k a r2)); (==) { lemma_pow_add k a (r1 * r3) r2 } k.mul x (pow k a (r1 * r3 + r2)); (==) { k.lemma_mul_comm x (pow k a (r1 * r3 + r2)) } k.mul (pow k a (r1 * r3 + r2)) x; } val exp_double_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (ensures exp_double_fw_f k a1 bBits b1 a2 b2 l (i - 1) acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let exp_double_fw_lemma_step #t k a1 bBits b1 a2 b2 l i acc = let acc1 = exp_pow2 k acc l in let r11 = b_acc l bBits b1 (i - 1) in let r12 = b_acc l bBits b1 i % pow2 l in let r21 = b_acc l bBits b2 (i - 1) in let r22 = b_acc l bBits b2 i % pow2 l in Math.Lemmas.distributivity_sub_right l i 1; let res_a1 = pow k a1 (b_acc l bBits b1 i) in let res_a2 = pow k a2 (b_acc l bBits b2 i) in calc (==) { k.mul acc1 (pow k a2 r22); (==) { exp_pow2_lemma k acc l } k.mul (pow k acc (pow2 l)) (pow k a2 r22); (==) { } k.mul (pow k (k.mul (pow k a1 r11) (pow k a2 r21)) (pow2 l)) (pow k a2 r22); (==) { lemma_pow_mul_base k (pow k a1 r11) (pow k a2 r21) (pow2 l) } k.mul (k.mul (pow k (pow k a1 r11) (pow2 l)) (pow k (pow k a2 r21) (pow2 l))) (pow k a2 r22); (==) { lemma_pow_distr_mul k (pow k (pow k a1 r11) (pow2 l)) a2 r21 r22 (pow2 l) } k.mul (pow k a2 (r21 * pow2 l + r22)) (pow k (pow k a1 r11) (pow2 l)); (==) { lemma_b_div_pow2ki bBits b2 l i } k.mul res_a2 (pow k (pow k a1 r11) (pow2 l)); }; calc (==) { k.mul (k.mul acc1 (pow k a2 r22)) (pow k a1 r12); (==) { } k.mul (k.mul res_a2 (pow k (pow k a1 r11) (pow2 l))) (pow k a1 r12); (==) { lemma_pow_distr_mul k res_a2 a1 r11 r12 (pow2 l) } k.mul (pow k a1 (r11 * pow2 l + r12)) res_a2; (==) { lemma_b_div_pow2ki bBits b1 l i } k.mul res_a1 res_a2; } val exp_double_fw_lemma_loop: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> i:nat{i <= bBits / l} -> Lemma ( let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in acc == mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) let rec exp_double_fw_lemma_loop #t k a1 bBits b1 a2 b2 l i = let acc0 = mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0)) in let acc = Loops.repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in if i = 0 then Loops.eq_repeati0 i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 else begin Loops.unfold_repeati i (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 (i - 1); let acc1 = Loops.repeati (i - 1) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in exp_double_fw_lemma_loop k a1 bBits b1 a2 b2 l (i - 1); exp_double_fw_lemma_step k a1 bBits b1 a2 b2 l i acc1; () end val exp_double_fw_acc0_lemma: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in acc0 == mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))) let exp_double_fw_acc0_lemma #t k a1 bBits b1 a2 b2 l = let bk = bBits - bBits % l in if bBits % l = 0 then begin let acc = one in assert (bBits / l * l == bBits); Math.Lemmas.small_div b1 (pow2 bBits); assert (b1 / pow2 (bBits / l * l) == 0); assert (b2 / pow2 (bBits / l * l) == 0); lemma_pow0 k a1; lemma_pow0 k a2; lemma_one k.one; assert (acc == mul (pow k a1 (b1 / pow2 bk)) (pow k a2 (b2 / pow2 bk))); () end else begin exp_fw_acc0_lemma #t k a1 bBits b1 l; exp_fw_acc0_lemma #t k a2 bBits b2 l end let exp_double_fw_lemma #t k a1 bBits b1 a2 b2 l = let acc0 = if bBits % l = 0 then one else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in exp_double_fw_acc0_lemma #t k a1 bBits b1 a2 b2 l; assert (acc0 == mul (pow k a1 (b_acc l bBits b1 0)) (pow k a2 (b_acc l bBits b2 0))); let res = Loops.repeati (bBits / l) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 in exp_double_fw_lemma_loop k a1 bBits b1 a2 b2 l (bBits / l); Math.Lemmas.euclidean_division_definition bBits l; assert_norm (pow2 0 = 1) //------------------------- val lemma_mul_assoc4: #t:Type -> k:comm_monoid t -> a1:t -> a2:t -> a3:t -> a4:t -> Lemma (k.mul a1 (k.mul (k.mul a2 a3) a4) == k.mul (k.mul (k.mul a1 a2) a3) a4) let lemma_mul_assoc4 #t k a1 a2 a3 a4 = calc (==) { k.mul a1 (k.mul (k.mul a2 a3) a4); (==) { k.lemma_mul_assoc a1 (k.mul a2 a3) a4 } k.mul (k.mul a1 (k.mul a2 a3)) a4; (==) { k.lemma_mul_assoc a1 a2 a3 } k.mul (k.mul (k.mul a1 a2) a3) a4; } val exp_four_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (pow k a3 (b_acc l bBits b3 (i - 1)))) (pow k a4 (b_acc l bBits b4 (i - 1)))) (ensures exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l (i - 1) acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i)))
false
false
Lib.Exponentiation.fst
{ "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" }
null
val exp_four_fw_lemma_step: #t:Type -> k:comm_monoid t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> a3:t -> b3:nat{b3 < pow2 bBits} -> a4:t -> b4:nat{b4 < pow2 bBits} -> l:pos -> i:pos{i <= bBits / l} -> acc:t -> Lemma (requires acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 (i - 1))) (pow k a2 (b_acc l bBits b2 (i - 1)))) (pow k a3 (b_acc l bBits b3 (i - 1)))) (pow k a4 (b_acc l bBits b4 (i - 1)))) (ensures exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l (i - 1) acc == k.mul (k.mul (k.mul (pow k a1 (b_acc l bBits b1 i)) (pow k a2 (b_acc l bBits b2 i))) (pow k a3 (b_acc l bBits b3 i))) (pow k a4 (b_acc l bBits b4 i)))
[]
Lib.Exponentiation.exp_four_fw_lemma_step
{ "file_name": "lib/Lib.Exponentiation.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> a3: t -> b3: Prims.nat{b3 < Prims.pow2 bBits} -> a4: t -> b4: Prims.nat{b4 < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.pos{i <= bBits / l} -> acc: t -> FStar.Pervasives.Lemma (requires acc == Mkcomm_monoid?.mul k (Mkcomm_monoid?.mul k (Mkcomm_monoid?.mul k (Lib.Exponentiation.Definition.pow k a1 (Lib.Exponentiation.b_acc l bBits b1 (i - 1))) (Lib.Exponentiation.Definition.pow k a2 (Lib.Exponentiation.b_acc l bBits b2 (i - 1)))) (Lib.Exponentiation.Definition.pow k a3 (Lib.Exponentiation.b_acc l bBits b3 (i - 1))) ) (Lib.Exponentiation.Definition.pow k a4 (Lib.Exponentiation.b_acc l bBits b4 (i - 1)))) (ensures Lib.Exponentiation.exp_four_fw_f k a1 bBits b1 a2 b2 a3 b3 a4 b4 l (i - 1) acc == Mkcomm_monoid?.mul k (Mkcomm_monoid?.mul k (Mkcomm_monoid?.mul k (Lib.Exponentiation.Definition.pow k a1 (Lib.Exponentiation.b_acc l bBits b1 i)) (Lib.Exponentiation.Definition.pow k a2 (Lib.Exponentiation.b_acc l bBits b2 i))) (Lib.Exponentiation.Definition.pow k a3 (Lib.Exponentiation.b_acc l bBits b3 i))) (Lib.Exponentiation.Definition.pow k a4 (Lib.Exponentiation.b_acc l bBits b4 i)))
{ "end_col": 3, "end_line": 656, "start_col": 71, "start_line": 572 }
Prims.Tot
val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ()))))))))))))
val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code let va_code_KeyExpansionRound round rcon =
false
null
false
(va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ()))))))))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Vale.X64.Memory.nat64", "Vale.X64.Memory.nat8", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsAes.va_code_AESNI_keygen_assist", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.InsVector.va_code_Pshufd", "Vale.X64.InsVector.va_code_VPslldq4", "Vale.X64.InsVector.va_code_Pxor", "Vale.X64.InsVector.va_code_Store128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Prims.op_Multiply", "Prims.op_Addition", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code
[]
Vale.AES.X64.AES128.va_code_KeyExpansionRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
round: Vale.X64.Memory.nat64 -> rcon: Vale.X64.Memory.nat8 -> Vale.X64.Decls.va_code
{ "end_col": 48, "end_line": 33, "start_col": 2, "start_line": 25 }
Prims.Tot
val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ())))))))))))
val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool let va_codegen_success_KeyExpansionRound round rcon =
false
null
false
(va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ())))))))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Vale.X64.Memory.nat64", "Vale.X64.Memory.nat8", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsAes.va_codegen_success_AESNI_keygen_assist", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.InsVector.va_codegen_success_Pshufd", "Vale.X64.InsVector.va_codegen_success_VPslldq4", "Vale.X64.InsVector.va_codegen_success_Pxor", "Vale.X64.InsVector.va_codegen_success_Store128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Prims.op_Multiply", "Prims.op_Addition", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool
[]
Vale.AES.X64.AES128.va_codegen_success_KeyExpansionRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
round: Vale.X64.Memory.nat64 -> rcon: Vale.X64.Memory.nat8 -> Vale.X64.Decls.va_pbool
{ "end_col": 84, "end_line": 48, "start_col": 2, "start_line": 38 }
Prims.Tot
val va_codegen_success_KeyExpansion128Stdcall : win:bool -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ())))))))
val va_codegen_success_KeyExpansion128Stdcall : win:bool -> Tot va_pbool let va_codegen_success_KeyExpansion128Stdcall win =
false
null
false
(va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ())))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsVector.va_codegen_success_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRcx", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_ttrue", "Vale.X64.Machine_s.rRdi", "Vale.X64.InsBasic.va_codegen_success_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRsi", "Vale.X64.Decls.va_pbool", "Vale.X64.InsVector.va_codegen_success_Store128_buffer", "Vale.AES.X64.AES128.va_codegen_success_KeyExpansionRoundUnrolledRecursive", "Vale.X64.InsVector.va_codegen_success_Pxor" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_KeyExpansion128Stdcall : win:bool -> Tot va_pbool
[]
Vale.AES.X64.AES128.va_codegen_success_KeyExpansion128Stdcall
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
win: Prims.bool -> Vale.X64.Decls.va_pbool
{ "end_col": 85, "end_line": 322, "start_col": 2, "start_line": 312 }
Prims.Tot
val va_code_AES128EncryptRound : n:nat -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ()))))
val va_code_AES128EncryptRound : n:nat -> Tot va_code let va_code_AES128EncryptRound n =
false
null
false
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ()))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Prims.nat", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsVector.va_code_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rR8", "Prims.op_Multiply", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.InsAes.va_code_AESNI_enc", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_AES128EncryptRound : n:nat -> Tot va_code
[]
Vale.AES.X64.AES128.va_code_AES128EncryptRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat -> Vale.X64.Decls.va_code
{ "end_col": 56, "end_line": 427, "start_col": 2, "start_line": 425 }
Prims.Tot
val va_code_KeyExpansion128Stdcall : win:bool -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ()))))))))
val va_code_KeyExpansion128Stdcall : win:bool -> Tot va_code let va_code_KeyExpansion128Stdcall win =
false
null
false
(va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))) ))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsVector.va_code_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRcx", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_CNil", "Vale.X64.Machine_s.rRdi", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRsi", "Vale.X64.Decls.va_code", "Vale.X64.InsVector.va_code_Store128_buffer", "Vale.AES.X64.AES128.va_code_KeyExpansionRoundUnrolledRecursive", "Vale.X64.InsVector.va_code_Pxor" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_KeyExpansion128Stdcall : win:bool -> Tot va_code
[]
Vale.AES.X64.AES128.va_code_KeyExpansion128Stdcall
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
win: Prims.bool -> Vale.X64.Decls.va_code
{ "end_col": 14, "end_line": 308, "start_col": 2, "start_line": 299 }
Prims.Tot
val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ())))
val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool let va_codegen_success_AES128EncryptRound n =
false
null
false
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ())))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Prims.nat", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsVector.va_codegen_success_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rR8", "Prims.op_Multiply", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.InsAes.va_codegen_success_AESNI_enc", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool
[]
Vale.AES.X64.AES128.va_codegen_success_AES128EncryptRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat -> Vale.X64.Decls.va_pbool
{ "end_col": 86, "end_line": 434, "start_col": 2, "start_line": 432 }
Prims.Tot
val va_codegen_success_AES128EncryptBlock : va_dummy:unit -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_codegen_success_AES128EncryptBlock () = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and (va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound 3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and (va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound 6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and (va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound 9) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_pbool_and (va_codegen_success_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_ttrue ())))))))))))))))
val va_codegen_success_AES128EncryptBlock : va_dummy:unit -> Tot va_pbool let va_codegen_success_AES128EncryptBlock () =
false
null
false
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and (va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound 3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and (va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound 6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and (va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound 9) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_pbool_and (va_codegen_success_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_ttrue ())))))))))))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Prims.unit", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsVector.va_codegen_success_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rR8", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.InsVector.va_codegen_success_Pxor", "Vale.AES.X64.AES128.va_codegen_success_AES128EncryptRound", "Prims.op_Multiply", "Vale.X64.InsAes.va_codegen_success_AESNI_enc_last", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer)) //-- //-- AES128EncryptBlock [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlock () = (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CNil ()))))))))))))))))) [@ "opaque_to_smt" va_qattr]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_AES128EncryptBlock : va_dummy:unit -> Tot va_pbool
[]
Vale.AES.X64.AES128.va_codegen_success_AES128EncryptBlock
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_dummy: Prims.unit -> Vale.X64.Decls.va_pbool
{ "end_col": 93, "end_line": 548, "start_col": 2, "start_line": 537 }
Prims.Tot
val va_codegen_success_AES128EncryptBlockStdcall : win:bool -> Tot va_pbool
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_codegen_success_AES128EncryptBlockStdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_AES128EncryptBlock ()) (va_pbool_and (if win then va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_ttrue ())) (va_ttrue ()))))
val va_codegen_success_AES128EncryptBlockStdcall : win:bool -> Tot va_pbool let va_codegen_success_AES128EncryptBlockStdcall win =
false
null
false
(va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_AES128EncryptBlock ()) (va_pbool_and (if win then va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_ttrue ())) (va_ttrue ()))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsVector.va_codegen_success_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_ttrue", "Vale.X64.Machine_s.rRsi", "Vale.X64.InsBasic.va_codegen_success_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rR8", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Decls.va_pbool", "Vale.AES.X64.AES128.va_codegen_success_AES128EncryptBlock", "Vale.X64.InsVector.va_codegen_success_Store128_buffer", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRdi" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer)) //-- //-- AES128EncryptBlock [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlock () = (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CNil ()))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlock () = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and (va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound 3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and (va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound 6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and (va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound 9) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_pbool_and (va_codegen_success_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 216 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let (i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336 s_337))) Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 218 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret keys_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 219 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 220 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 222 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 223 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 224 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 225 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 226 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 227 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 228 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg20) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret keys_buffer 10) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 234 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 235 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptBlock va_b0 va_s0 input key round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptBlock va_mods input key round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlock ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 193 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 214 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptBlock (va_code_AES128EncryptBlock ()) va_s0 input key round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptBlockStdcall [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlockStdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_CNil ())))) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_AES128EncryptBlock ()) (va_CCons (if win then va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ()))) (va_CNil ())))))) [@ "opaque_to_smt" va_qattr]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_AES128EncryptBlockStdcall : win:bool -> Tot va_pbool
[]
Vale.AES.X64.AES128.va_codegen_success_AES128EncryptBlockStdcall
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
win: Prims.bool -> Vale.X64.Decls.va_pbool
{ "end_col": 63, "end_line": 652, "start_col": 2, "start_line": 643 }
Prims.Tot
val va_code_AES128EncryptBlock : va_dummy:unit -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_code_AES128EncryptBlock () = (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CNil ())))))))))))))))))
val va_code_AES128EncryptBlock : va_dummy:unit -> Tot va_code let va_code_AES128EncryptBlock () =
false
null
false
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2 ) (va_op_xmm_xmm 2)) (va_CNil ())))))))))))))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Prims.unit", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.Decls.va_CNil", "Vale.X64.InsVector.va_code_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rR8", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.InsVector.va_code_Pxor", "Vale.AES.X64.AES128.va_code_AES128EncryptRound", "Prims.op_Multiply", "Vale.X64.InsAes.va_code_AESNI_enc_last", "Vale.X64.Decls.va_code" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer)) //-- //-- AES128EncryptBlock [@ "opaque_to_smt" va_qattr]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_AES128EncryptBlock : va_dummy:unit -> Tot va_code
[]
Vale.AES.X64.AES128.va_code_AES128EncryptBlock
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_dummy: Prims.unit -> Vale.X64.Decls.va_code
{ "end_col": 23, "end_line": 533, "start_col": 2, "start_line": 523 }
Prims.Tot
val va_code_AES128EncryptBlockStdcall : win:bool -> Tot va_code
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_code_AES128EncryptBlockStdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_CNil ())))) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_AES128EncryptBlock ()) (va_CCons (if win then va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ()))) (va_CNil ()))))))
val va_code_AES128EncryptBlockStdcall : win:bool -> Tot va_code let va_code_AES128EncryptBlockStdcall win =
false
null
false
(va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_CNil ())))) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_AES128EncryptBlock ()) (va_CCons (if win then va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ()))) (va_CNil ()))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsVector.va_code_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_CNil", "Vale.X64.Machine_s.rRsi", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rR8", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Decls.va_code", "Vale.AES.X64.AES128.va_code_AES128EncryptBlock", "Vale.X64.InsVector.va_code_Store128_buffer", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRdi" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer)) //-- //-- AES128EncryptBlock [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlock () = (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CNil ()))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlock () = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and (va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound 3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and (va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound 6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and (va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound 9) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_pbool_and (va_codegen_success_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 216 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let (i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336 s_337))) Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 218 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret keys_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 219 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 220 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 222 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 223 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 224 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 225 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 226 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 227 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 228 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg20) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret keys_buffer 10) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 234 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 235 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptBlock va_b0 va_s0 input key round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptBlock va_mods input key round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlock ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 193 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 214 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptBlock (va_code_AES128EncryptBlock ()) va_s0 input key round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptBlockStdcall [@ "opaque_to_smt" va_qattr]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_AES128EncryptBlockStdcall : win:bool -> Tot va_code
[]
Vale.AES.X64.AES128.va_code_AES128EncryptBlockStdcall
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
win: Prims.bool -> Vale.X64.Decls.va_code
{ "end_col": 27, "end_line": 639, "start_col": 2, "start_line": 630 }
Prims.Tot
val va_wp_KeyExpansionRound (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (())))
val va_wp_KeyExpansionRound (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_KeyExpansionRound (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem: vale_heap) (va_x_heap1: vale_heap) (va_x_xmm1: quad32) (va_x_xmm2: quad32) (va_x_xmm3: quad32) (va_x_efl: Vale.X64.Flags.t). let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Vale.X64.Memory.nat64", "Vale.X64.Memory.nat8", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.Decls.validDstAddrs128", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRdx", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.CPU_Features_s.aesni_enabled", "Vale.X64.CPU_Features_s.avx_enabled", "Vale.X64.CPU_Features_s.sse_enabled", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.eq2", "Prims.nat", "Prims.l_or", "Vale.Def.Words_s.pow2_8", "Vale.Def.Words_s.pow2_32", "Vale.AES.AES_common_s.aes_rcon", "Vale.AES.AES_s.is_aes_key_LE", "Vale.AES.AES_common_s.AES_128", "Vale.Def.Types_s.quad32", "Vale.X64.Decls.va_get_xmm", "Vale.AES.AES_helpers.expand_key_128", "Prims.l_Forall", "Vale.X64.InsBasic.vale_heap", "Vale.X64.Decls.quad32", "Vale.X64.Flags.t", "Prims.l_imp", "Vale.X64.Decls.buffer128_read", "Prims.op_Addition", "Vale.X64.Decls.modifies_buffer_specific128", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_flags", "Vale.X64.Decls.va_upd_xmm", "Vale.X64.Decls.va_upd_mem_heaplet", "Vale.X64.Decls.va_upd_mem" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32))
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_KeyExpansionRound (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.X64.AES128.va_wp_KeyExpansionRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
round: Vale.X64.Memory.nat64 -> rcon: Vale.X64.Memory.nat8 -> dst: Vale.X64.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 58, "end_line": 143, "start_col": 2, "start_line": 130 }
Prims.Tot
val va_wp_KeyExpansionRoundUnrolledRecursive (key: (seq nat32)) (dst: buffer128) (n: int) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (())))
val va_wp_KeyExpansionRoundUnrolledRecursive (key: (seq nat32)) (dst: buffer128) (n: int) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_KeyExpansionRoundUnrolledRecursive (key: (seq nat32)) (dst: buffer128) (n: int) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem: vale_heap) (va_x_heap1: vale_heap) (va_x_xmm1: quad32) (va_x_xmm2: quad32) (va_x_xmm3: quad32) (va_x_efl: Vale.X64.Flags.t). let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j. {:pattern (buffer128_read dst j (va_get_mem_heaplet 1 va_sM))} 0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Memory.buffer128", "Prims.int", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.Decls.validDstAddrs128", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRdx", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.CPU_Features_s.aesni_enabled", "Vale.X64.CPU_Features_s.avx_enabled", "Vale.X64.CPU_Features_s.sse_enabled", "Prims.op_LessThanOrEqual", "Vale.AES.AES_s.is_aes_key_LE", "Vale.AES.AES_common_s.AES_128", "Prims.eq2", "Vale.Arch.Types.quad32_to_seq", "Vale.X64.Decls.va_get_xmm", "Vale.X64.Decls.quad32", "Vale.X64.Decls.buffer128_read", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.vuint128", "Prims.l_Forall", "Vale.X64.InsBasic.vale_heap", "Vale.X64.Flags.t", "Prims.l_imp", "Vale.X64.Decls.modifies_buffer128", "Prims.op_GreaterThanOrEqual", "Vale.Def.Types_s.quad32", "Vale.AES.AES_helpers.expand_key_128", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_flags", "Vale.X64.Decls.va_upd_xmm", "Vale.X64.Decls.va_upd_mem_heaplet", "Vale.X64.Decls.va_upd_mem" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int)
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_KeyExpansionRoundUnrolledRecursive (key: (seq nat32)) (dst: buffer128) (n: int) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.X64.AES128.va_wp_KeyExpansionRoundUnrolledRecursive
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> dst: Vale.X64.Memory.buffer128 -> n: Prims.int -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 68, "end_line": 265, "start_col": 2, "start_line": 250 }
Prims.Tot
val va_quick_KeyExpansionRound (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key))
val va_quick_KeyExpansionRound (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) let va_quick_KeyExpansionRound (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) =
false
null
false
(va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Vale.X64.Memory.nat64", "Vale.X64.Memory.nat8", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.AES.X64.AES128.va_code_KeyExpansionRound", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "Vale.AES.X64.AES128.va_wp_KeyExpansionRound", "Vale.AES.X64.AES128.va_wpProof_KeyExpansionRound", "Vale.X64.QuickCode.va_quickCode" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) :
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_KeyExpansionRound (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon))
[]
Vale.AES.X64.AES128.va_quick_KeyExpansionRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
round: Vale.X64.Memory.nat64 -> rcon: Vale.X64.Memory.nat8 -> dst: Vale.X64.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.AES128.va_code_KeyExpansionRound round rcon)
{ "end_col": 54, "end_line": 171, "start_col": 2, "start_line": 169 }
Prims.Tot
val va_quick_KeyExpansionRoundUnrolledRecursive (key: (seq nat32)) (dst: buffer128) (n: int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n))
val va_quick_KeyExpansionRoundUnrolledRecursive (key: (seq nat32)) (dst: buffer128) (n: int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) let va_quick_KeyExpansionRoundUnrolledRecursive (key: (seq nat32)) (dst: buffer128) (n: int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) =
false
null
false
(va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Memory.buffer128", "Prims.int", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.AES.X64.AES128.va_code_KeyExpansionRoundUnrolledRecursive", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "Vale.AES.X64.AES128.va_wp_KeyExpansionRoundUnrolledRecursive", "Vale.AES.X64.AES128.va_wpProof_KeyExpansionRoundUnrolledRecursive", "Vale.X64.QuickCode.va_quickCode" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) :
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_KeyExpansionRoundUnrolledRecursive (key: (seq nat32)) (dst: buffer128) (n: int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n))
[]
Vale.AES.X64.AES128.va_quick_KeyExpansionRoundUnrolledRecursive
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> dst: Vale.X64.Memory.buffer128 -> n: Prims.int -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.AES128.va_code_KeyExpansionRoundUnrolledRecursive n)
{ "end_col": 73, "end_line": 293, "start_col": 2, "start_line": 291 }
Prims.Ghost
val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem ]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "Vale.X64.Memory.nat64", "Vale.X64.Memory.nat8", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "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_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_flags", "Vale.X64.Decls.va_update_xmm", "Vale.X64.Decls.va_update_mem_heaplet", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_mem", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.AES.X64.AES128.va_lemma_KeyExpansionRound", "Vale.AES.X64.AES128.va_code_KeyExpansionRound" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.AES.X64.AES128.va_wpProof_KeyExpansionRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
round: Vale.X64.Memory.nat64 -> rcon: Vale.X64.Memory.nat8 -> dst: Vale.X64.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> 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)
{ "end_col": 22, "end_line": 164, "start_col": 64, "start_line": 154 }
Prims.Tot
val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n])
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ()))
val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n =
false
null
false
(va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ()))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total", "" ]
[ "Prims.int", "Vale.X64.Decls.va_pbool_and", "Prims.op_AmpAmp", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Vale.AES.X64.AES128.va_codegen_success_KeyExpansionRoundUnrolledRecursive", "Prims.op_Subtraction", "Vale.AES.X64.AES128.va_codegen_success_KeyExpansionRound", "Vale.AES.AES_common_s.aes_rcon", "Vale.X64.Decls.va_ttrue", "Prims.bool", "Vale.X64.Decls.va_pbool" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n])
[ "recursion" ]
Vale.AES.X64.AES128.va_codegen_success_KeyExpansionRoundUnrolledRecursive
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.int -> Prims.Tot Vale.X64.Decls.va_pbool
{ "end_col": 51, "end_line": 189, "start_col": 2, "start_line": 186 }
Prims.Tot
val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n])
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ())))
val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) let rec va_code_KeyExpansionRoundUnrolledRecursive n =
false
null
false
(va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ())))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total", "" ]
[ "Prims.int", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Prims.op_AmpAmp", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Vale.AES.X64.AES128.va_code_KeyExpansionRoundUnrolledRecursive", "Prims.op_Subtraction", "Vale.AES.X64.AES128.va_code_KeyExpansionRound", "Vale.AES.AES_common_s.aes_rcon", "Vale.X64.Decls.va_CNil", "Prims.bool", "Vale.X64.Decls.va_code" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"]
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n])
[ "recursion" ]
Vale.AES.X64.AES128.va_code_KeyExpansionRoundUnrolledRecursive
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.int -> Prims.Tot Vale.X64.Decls.va_code
{ "end_col": 18, "end_line": 181, "start_col": 2, "start_line": 178 }
Prims.Tot
val va_qcode_KeyExpansionRound (va_mods: va_mods_t) (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (())))))))))))))))
val va_qcode_KeyExpansionRound (va_mods: va_mods_t) (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) let va_qcode_KeyExpansionRound (va_mods: va_mods_t) (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) =
false
null
false
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1 ) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s: va_state) _ -> let va_arg15:Vale.Def.Types_s.nat32 = rcon in let va_arg14:Vale.Def.Types_s.quad32 = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_: unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_: unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (())))))))))))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.Memory.nat64", "Vale.X64.Memory.nat8", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsAes.va_code_AESNI_keygen_assist", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.InsVector.va_code_Pshufd", "Vale.X64.InsVector.va_code_VPslldq4", "Vale.X64.InsVector.va_code_Pxor", "Vale.X64.InsVector.va_code_Store128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Prims.op_Multiply", "Prims.op_Addition", "Vale.Arch.HeapTypes_s.Secret", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsAes.va_quick_AESNI_keygen_assist", "Vale.X64.InsVector.va_quick_Pshufd", "Vale.X64.InsVector.va_quick_VPslldq4", "Vale.X64.InsVector.va_quick_Pxor", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.InsVector.va_quick_Store128_buffer", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "Vale.Def.Types_s.quad32", "Vale.AES.AES_helpers.simd_round_key_128", "Vale.AES.AES_helpers.round_key_128_rcon", "Vale.AES.AES_helpers.lemma_simd_round_key", "Vale.Def.Words_s.nat32", "Prims.nat", "Vale.AES.AES_s.is_aes_key_LE", "Vale.AES.AES_common_s.AES_128", "Vale.AES.AES_helpers.expand_key_128", "Vale.AES.AES_helpers.expand_key_128_def", "Vale.AES.AES_helpers.expand_key_128_reveal", "Vale.X64.QuickCodes.va_QEmpty", "Vale.X64.Decls.va_get_xmm", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.AES.X64.AES128.va_code_KeyExpansionRound" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128)
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_qcode_KeyExpansionRound (va_mods: va_mods_t) (round: nat64) (rcon: nat8) (dst: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon))
[]
Vale.AES.X64.AES128.va_qcode_KeyExpansionRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_mods: Vale.X64.QuickCode.va_mods_t -> round: Vale.X64.Memory.nat64 -> rcon: Vale.X64.Memory.nat8 -> dst: Vale.X64.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.AES128.va_code_KeyExpansionRound round rcon)
{ "end_col": 97, "end_line": 81, "start_col": 2, "start_line": 53 }
Prims.Ghost
val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem ]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Memory.buffer128", "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_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_flags", "Vale.X64.Decls.va_update_xmm", "Vale.X64.Decls.va_update_mem_heaplet", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_mem", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.AES.X64.AES128.va_lemma_KeyExpansionRoundUnrolledRecursive", "Vale.AES.X64.AES128.va_code_KeyExpansionRoundUnrolledRecursive" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.AES.X64.AES128.va_wpProof_KeyExpansionRoundUnrolledRecursive
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> dst: Vale.X64.Memory.buffer128 -> n: 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)
{ "end_col": 22, "end_line": 286, "start_col": 72, "start_line": 276 }
Prims.Tot
val va_qcode_AES128EncryptRound (va_mods: va_mods_t) (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (()))))))
val va_qcode_AES128EncryptRound (va_mods: va_mods_t) (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) let va_qcode_AES128EncryptRound (va_mods: va_mods_t) (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) =
false
null
false
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in let va_arg5:Vale.Def.Types_s.quad32 = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_: unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (()))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.va_mods_t", "Prims.nat", "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.buffer128", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsVector.va_code_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rR8", "Prims.op_Multiply", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.InsAes.va_code_AESNI_enc", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "Vale.Def.Types_s.quad32", "Vale.AES.AES_common_s.sub_bytes", "Vale.AES.AES_s.shift_rows_LE", "Vale.X64.QuickCodes.va_range1", "Vale.AES.AES_s.commute_sub_bytes_shift_rows", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.InsVector.va_quick_Load128_buffer", "Vale.X64.InsAes.va_quick_AESNI_enc", "Vale.X64.QuickCodes.va_QEmpty", "Vale.X64.Decls.va_get_xmm", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.QuickCode.va_quickCode", "Vale.AES.X64.AES128.va_code_AES128EncryptRound" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32))
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_qcode_AES128EncryptRound (va_mods: va_mods_t) (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n))
[]
Vale.AES.X64.AES128.va_qcode_AES128EncryptRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_mods: Vale.X64.QuickCode.va_mods_t -> n: Prims.nat -> init: Vale.X64.Decls.quad32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_buffer: Vale.X64.Memory.buffer128 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.AES128.va_code_AES128EncryptRound n)
{ "end_col": 81, "end_line": 447, "start_col": 2, "start_line": 439 }
Prims.Tot
val va_quick_AES128EncryptRound (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer))
val va_quick_AES128EncryptRound (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) let va_quick_AES128EncryptRound (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) =
false
null
false
(va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Prims.nat", "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.buffer128", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.AES.X64.AES128.va_code_AES128EncryptRound", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Prims.Nil", "Vale.AES.X64.AES128.va_wp_AES128EncryptRound", "Vale.AES.X64.AES128.va_wpProof_AES128EncryptRound", "Vale.X64.QuickCode.va_quickCode" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32))
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_AES128EncryptRound (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n))
[]
Vale.AES.X64.AES128.va_quick_AES128EncryptRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat -> init: Vale.X64.Decls.quad32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_buffer: Vale.X64.Memory.buffer128 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.AES128.va_code_AES128EncryptRound n)
{ "end_col": 28, "end_line": 517, "start_col": 2, "start_line": 515 }
Prims.Tot
val va_wp_AES128EncryptRound (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (())))
val va_wp_AES128EncryptRound (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_AES128EncryptRound (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0: quad32) (va_x_xmm2: quad32) (va_x_efl: Vale.X64.Flags.t). let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Prims.nat", "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.buffer128", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.CPU_Features_s.aesni_enabled", "Vale.X64.CPU_Features_s.sse_enabled", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "FStar.Seq.Base.length", "Prims.eq2", "Vale.Def.Types_s.quad32", "Vale.X64.Decls.va_get_xmm", "Vale.AES.AES_s.eval_rounds_def", "Prims.op_Subtraction", "Prims.int", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rR8", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.vuint128", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.validSrcAddrs128", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.buffer128_read", "FStar.Seq.Base.index", "Prims.l_Forall", "Vale.X64.Flags.t", "Prims.l_imp", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_flags", "Vale.X64.Decls.va_upd_xmm" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32))
false
true
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_AES128EncryptRound (n: nat) (init: quad32) (round_keys: (seq quad32)) (keys_buffer: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.X64.AES128.va_wp_AES128EncryptRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat -> init: Vale.X64.Decls.quad32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_buffer: Vale.X64.Memory.buffer128 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 96, "end_line": 491, "start_col": 2, "start_line": 482 }
Prims.Ghost
val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "Prims.nat", "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.buffer128", "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_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_flags", "Vale.X64.Decls.va_update_xmm", "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.AES.X64.AES128.va_lemma_AES128EncryptRound", "Vale.AES.X64.AES128.va_code_AES128EncryptRound" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.AES.X64.AES128.va_wpProof_AES128EncryptRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat -> init: Vale.X64.Decls.quad32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_buffer: Vale.X64.Memory.buffer128 -> 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)
{ "end_col": 22, "end_line": 510, "start_col": 76, "start_line": 502 }
Prims.Ghost
val va_wpProof_KeyExpansion128Stdcall : win:bool -> input_key_b:buffer128 -> output_key_expansion_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansion128Stdcall win) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_KeyExpansion128Stdcall : win:bool -> input_key_b:buffer128 -> output_key_expansion_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansion128Stdcall win) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem ]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "Prims.bool", "Vale.X64.Memory.buffer128", "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_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRdx", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_flags", "Vale.X64.Decls.va_update_xmm", "Vale.X64.Decls.va_update_mem_heaplet", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_mem", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.AES.X64.AES128.va_lemma_KeyExpansion128Stdcall", "Vale.AES.X64.AES128.va_code_KeyExpansion128Stdcall" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM)
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_KeyExpansion128Stdcall : win:bool -> input_key_b:buffer128 -> output_key_expansion_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansion128Stdcall win) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.AES.X64.AES128.va_wpProof_KeyExpansion128Stdcall
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
win: Prims.bool -> input_key_b: Vale.X64.Memory.buffer128 -> output_key_expansion_b: Vale.X64.Memory.buffer128 -> 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)
{ "end_col": 22, "end_line": 417, "start_col": 89, "start_line": 407 }
Prims.Tot
val va_qcode_KeyExpansion128Stdcall (va_mods: va_mods_t) (win: bool) (input_key_b output_key_expansion_b: buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (())))))))))))
val va_qcode_KeyExpansion128Stdcall (va_mods: va_mods_t) (win: bool) (input_key_b output_key_expansion_b: buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) let va_qcode_KeyExpansion128Stdcall (va_mods: va_mods_t) (win: bool) (input_key_b output_key_expansion_b: buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) =
false
null
false
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in let key_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let key_expansion_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s: va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s: va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s: va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s: va_state) _ -> let va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_: unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (())))))))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.va_mods_t", "Prims.bool", "Vale.X64.Memory.buffer128", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.QuickCodes.if_code", "Vale.X64.QuickCodes.block", "Vale.X64.InsVector.va_code_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRcx", "Vale.Arch.HeapTypes_s.Secret", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Machine_s.rRdi", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRsi", "Vale.X64.InsVector.va_code_Store128_buffer", "Vale.AES.X64.AES128.va_code_KeyExpansionRoundUnrolledRecursive", "Vale.X64.InsVector.va_code_Pxor", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.QuickCodes.va_range1", "Vale.X64.QuickCodes.va_qInlineIf", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.InsVector.va_quick_Load128_buffer", "Vale.X64.QuickCodes.va_QEmpty", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.InsBasic.va_quick_Mov64", "Vale.X64.InsVector.va_quick_Store128_buffer", "Vale.AES.X64.AES128.va_quick_KeyExpansionRoundUnrolledRecursive", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Vale.AES.AES_s.is_aes_key_LE", "Vale.AES.AES_common_s.AES_128", "Prims.l_Forall", "Prims.l_imp", "Prims.nat", "Prims.op_LessThan", "Prims.eq2", "Vale.Def.Types_s.quad32", "Vale.AES.AES_helpers.expand_key_128", "FStar.Seq.Base.index", "Vale.AES.AES_s.key_schedule_to_round_keys", "Vale.AES.AES_s.expand_key", "Vale.AES.AES_helpers.expand_key_128_def", "Vale.AES.AES_helpers.lemma_expand_key_128", "Vale.X64.QuickCodes.va_QLemma", "Prims.squash", "Vale.X64.Decls.va_reveal_eq", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Prims.int", "FStar.Seq.Base.length", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "Vale.AES.AES_s.key_to_round_keys_LE", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsVector.va_quick_Pxor", "Vale.Def.Words_s.nat32", "Vale.Arch.Types.quad32_to_seq", "Vale.X64.Decls.buffer128_read", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.va_int_range", "Vale.X64.Decls.va_if", "Vale.Def.Types_s.nat64", "Vale.X64.Decls.va_get_reg64", "Prims.l_not", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.AES.X64.AES128.va_code_KeyExpansion128Stdcall" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128)
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_qcode_KeyExpansion128Stdcall (va_mods: va_mods_t) (win: bool) (input_key_b output_key_expansion_b: buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win))
[]
Vale.AES.X64.AES128.va_qcode_KeyExpansion128Stdcall
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_mods: Vale.X64.QuickCode.va_mods_t -> win: Prims.bool -> input_key_b: Vale.X64.Memory.buffer128 -> output_key_expansion_b: Vale.X64.Memory.buffer128 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.AES128.va_code_KeyExpansion128Stdcall win)
{ "end_col": 81, "end_line": 363, "start_col": 2, "start_line": 327 }
Prims.Ghost
val va_wpProof_AES128EncryptBlock : input:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptBlock ()) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wpProof_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptBlock (va_code_AES128EncryptBlock ()) va_s0 input key round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_AES128EncryptBlock : input:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptBlock ()) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_AES128EncryptBlock (va_code_AES128EncryptBlock ()) va_s0 input key round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Memory.buffer128", "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_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_flags", "Vale.X64.Decls.va_update_xmm", "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.AES.X64.AES128.va_lemma_AES128EncryptBlock", "Vale.AES.X64.AES128.va_code_AES128EncryptBlock" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer)) //-- //-- AES128EncryptBlock [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlock () = (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CNil ()))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlock () = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and (va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound 3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and (va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound 6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and (va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound 9) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_pbool_and (va_codegen_success_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 216 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let (i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336 s_337))) Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 218 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret keys_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 219 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 220 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 222 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 223 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 224 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 225 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 226 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 227 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 228 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg20) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret keys_buffer 10) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 234 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 235 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptBlock va_b0 va_s0 input key round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptBlock va_mods input key round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlock ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 193 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 214 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_AES128EncryptBlock : input:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptBlock ()) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.AES.X64.AES128.va_wpProof_AES128EncryptBlock
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
input: Vale.X64.Decls.quad32 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_buffer: Vale.X64.Memory.buffer128 -> 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)
{ "end_col": 22, "end_line": 623, "start_col": 79, "start_line": 615 }
Prims.Tot
val va_qcode_AES128EncryptBlockStdcall (va_mods: va_mods_t) (win: bool) (input: quad32) (key: (seq nat32)) (input_buffer output_buffer keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptBlockStdcall win))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_qcode_AES128EncryptBlockStdcall (va_mods:va_mods_t) (win:bool) (input:quad32) (key:(seq nat32)) (input_buffer:buffer128) (output_buffer:buffer128) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlockStdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (output_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (input_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s) (fun _ -> va_get_reg64 rRdx va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 271 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret input_buffer 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 277 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret input_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 278 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun (alg_10095:Vale.AES.AES_common_s.algorithm) (key_10096:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) -> Vale.AES.AES_s.is_aes_key_LE alg_10095 key_10096) AES_128 key) (fun _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptBlock input key (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) keys_buffer) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 283 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 285 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret output_buffer 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret output_buffer 0) (va_QEmpty (()))))) (fun (va_s:va_state) va_g -> va_QEmpty (())))))))
val va_qcode_AES128EncryptBlockStdcall (va_mods: va_mods_t) (win: bool) (input: quad32) (key: (seq nat32)) (input_buffer output_buffer keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptBlockStdcall win)) let va_qcode_AES128EncryptBlockStdcall (va_mods: va_mods_t) (win: bool) (input: quad32) (key: (seq nat32)) (input_buffer output_buffer keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptBlockStdcall win)) =
false
null
false
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in let output_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let input_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let expanded_key_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rR8 va_s) (fun _ -> va_get_reg64 rRdx va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 271 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s: va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret input_buffer 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s: va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 277 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret input_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 278 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_QEmpty (())))))) (fun (va_s: va_state) va_g -> va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun (alg_10095: Vale.AES.AES_common_s.algorithm) (key_10096: (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) -> Vale.AES.AES_s.is_aes_key_LE alg_10095 key_10096) AES_128 key) (fun _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptBlock input key (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) keys_buffer) (fun (va_s: va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 283 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s: va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 285 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret output_buffer 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s: va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret output_buffer 0) (va_QEmpty (()))))) (fun (va_s: va_state) va_g -> va_QEmpty (())))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.va_mods_t", "Prims.bool", "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Memory.buffer128", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.QuickCodes.if_code", "Vale.X64.QuickCodes.block", "Vale.X64.InsVector.va_code_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRdx", "Vale.Arch.HeapTypes_s.Secret", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Machine_s.rRsi", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rR8", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.Block", "Vale.AES.X64.AES128.va_code_AES128EncryptBlock", "Vale.X64.InsVector.va_code_Store128_buffer", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRdi", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.QuickCodes.va_range1", "Vale.X64.QuickCodes.va_qInlineIf", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.InsVector.va_quick_Load128_buffer", "Vale.X64.QuickCodes.va_QEmpty", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.InsBasic.va_quick_Mov64", "Vale.X64.QuickCodes.va_qAssertSquash", "Vale.AES.AES_s.is_aes_key_LE", "Vale.AES.AES_common_s.AES_128", "Prims.squash", "Vale.AES.X64.AES128.va_quick_AES128EncryptBlock", "Vale.AES.AES_s.key_to_round_keys_LE", "Vale.X64.InsVector.va_quick_Store128_buffer", "Vale.X64.Decls.va_int_range", "Vale.X64.Decls.va_if", "Vale.Def.Types_s.nat64", "Prims.b2t", "Vale.X64.Decls.va_get_reg64", "Prims.l_not", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.AES.X64.AES128.va_code_AES128EncryptBlockStdcall" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer)) //-- //-- AES128EncryptBlock [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlock () = (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CNil ()))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlock () = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and (va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound 3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and (va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound 6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and (va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound 9) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_pbool_and (va_codegen_success_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 216 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let (i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336 s_337))) Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 218 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret keys_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 219 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 220 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 222 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 223 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 224 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 225 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 226 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 227 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 228 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg20) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret keys_buffer 10) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 234 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 235 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptBlock va_b0 va_s0 input key round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptBlock va_mods input key round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlock ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 193 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 214 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptBlock (va_code_AES128EncryptBlock ()) va_s0 input key round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptBlockStdcall [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlockStdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_CNil ())))) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_AES128EncryptBlock ()) (va_CCons (if win then va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ()))) (va_CNil ())))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlockStdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_AES128EncryptBlock ()) (va_pbool_and (if win then va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_ttrue ())) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlockStdcall (va_mods:va_mods_t) (win:bool) (input:quad32) (key:(seq nat32)) (input_buffer:buffer128) (output_buffer:buffer128) (keys_buffer:buffer128) :
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_qcode_AES128EncryptBlockStdcall (va_mods: va_mods_t) (win: bool) (input: quad32) (key: (seq nat32)) (input_buffer output_buffer keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptBlockStdcall win))
[]
Vale.AES.X64.AES128.va_qcode_AES128EncryptBlockStdcall
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_mods: Vale.X64.QuickCode.va_mods_t -> win: Prims.bool -> input: Vale.X64.Decls.quad32 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> input_buffer: Vale.X64.Memory.buffer128 -> output_buffer: Vale.X64.Memory.buffer128 -> keys_buffer: Vale.X64.Memory.buffer128 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.AES128.va_code_AES128EncryptBlockStdcall win)
{ "end_col": 24, "end_line": 692, "start_col": 2, "start_line": 658 }
Prims.Tot
val va_qcode_AES128EncryptBlock (va_mods: va_mods_t) (input: quad32) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ()))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 216 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let (i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336 s_337))) Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 218 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret keys_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 219 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 220 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 222 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 223 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 224 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 225 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 226 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 227 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 228 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg20) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret keys_buffer 10) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 234 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 235 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QEmpty (()))))))))))))))))))))
val va_qcode_AES128EncryptBlock (va_mods: va_mods_t) (input: quad32) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ())) let va_qcode_AES128EncryptBlock (va_mods: va_mods_t) (input: quad32) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ())) =
false
null
false
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 216 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun a_336 (s_337: (FStar.Seq.Base.seq a_336)) (i_338: Prims.nat) -> let i_312:Prims.nat = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336 s_337))) Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let init:Vale.Def.Types_s.quad32 = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 218 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret keys_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 219 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 220 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 222 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 223 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 224 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 225 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 226 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 227 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 228 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (fun (va_s: va_state) _ -> let va_arg20:Vale.Def.Types_s.quad32 = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_: unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg20) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret keys_buffer 10) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 234 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (fun (va_s: va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 235 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_: unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QEmpty (())))))) ))))))))))))))
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "total" ]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Memory.buffer128", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.Machine_s.Block", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.InsVector.va_code_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rR8", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.InsVector.va_code_Pxor", "Vale.AES.X64.AES128.va_code_AES128EncryptRound", "Prims.op_Multiply", "Vale.X64.InsAes.va_code_AESNI_enc_last", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_qAssertSquash", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.squash", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.InsVector.va_quick_Load128_buffer", "Vale.X64.InsVector.va_quick_Pxor", "Vale.AES.X64.AES128.va_quick_AES128EncryptRound", "Vale.X64.QuickCodes.va_QBind", "Vale.X64.QuickCodes.va_qPURE", "Prims.pure_post", "Prims.l_and", "Prims.l_True", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "Vale.AES.AES_common_s.sub_bytes", "Vale.AES.AES_s.shift_rows_LE", "Vale.AES.AES_s.commute_sub_bytes_shift_rows", "Vale.X64.InsAes.va_quick_AESNI_enc_last", "Vale.AES.AES_common_s.algorithm", "Vale.Def.Words_s.nat32", "Vale.AES.AES_s.is_aes_key_LE", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.AES.AES_s.aes_encrypt_LE_def", "Vale.AES.AES_s.aes_encrypt_LE_reveal", "Vale.X64.QuickCodes.va_QEmpty", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.Decls.va_get_xmm", "Vale.Def.Types_s.quad32_xor", "FStar.Seq.Base.index", "Vale.X64.State.vale_state", "Vale.X64.QuickCode.va_quickCode", "Vale.AES.X64.AES128.va_code_AES128EncryptBlock" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer)) //-- //-- AES128EncryptBlock [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlock () = (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CNil ()))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlock () = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and (va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound 3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and (va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound 6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and (va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound 9) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_pbool_and (va_codegen_success_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_qcode_AES128EncryptBlock (va_mods: va_mods_t) (input: quad32) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_buffer: buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ()))
[]
Vale.AES.X64.AES128.va_qcode_AES128EncryptBlock
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_mods: Vale.X64.QuickCode.va_mods_t -> input: Vale.X64.Decls.quad32 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_buffer: Vale.X64.Memory.buffer128 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.AES128.va_code_AES128EncryptBlock ())
{ "end_col": 96, "end_line": 597, "start_col": 2, "start_line": 554 }
Prims.Ghost
val va_wpProof_AES128EncryptBlockStdcall : win:bool -> input:quad32 -> key:(seq nat32) -> input_buffer:buffer128 -> output_buffer:buffer128 -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptBlockStdcall win input key input_buffer output_buffer keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptBlockStdcall win) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wpProof_AES128EncryptBlockStdcall win input key input_buffer output_buffer keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptBlockStdcall (va_code_AES128EncryptBlockStdcall win) va_s0 win input key input_buffer output_buffer keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
val va_wpProof_AES128EncryptBlockStdcall : win:bool -> input:quad32 -> key:(seq nat32) -> input_buffer:buffer128 -> output_buffer:buffer128 -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptBlockStdcall win input key input_buffer output_buffer keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptBlockStdcall win) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) let va_wpProof_AES128EncryptBlockStdcall win input key input_buffer output_buffer keys_buffer va_s0 va_k =
false
null
false
let va_sM, va_f0 = va_lemma_AES128EncryptBlockStdcall (va_code_AES128EncryptBlockStdcall win) va_s0 win input key input_buffer output_buffer keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))) ))); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_mem ]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "Prims.bool", "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Memory.buffer128", "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_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR8", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_flags", "Vale.X64.Decls.va_update_xmm", "Vale.X64.Decls.va_update_mem_heaplet", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_mem", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.AES.X64.AES128.va_lemma_AES128EncryptBlockStdcall", "Vale.AES.X64.AES128.va_code_AES128EncryptBlockStdcall" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer)) //-- //-- AES128EncryptBlock [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlock () = (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CNil ()))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlock () = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and (va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound 3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and (va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound 6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and (va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound 9) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_pbool_and (va_codegen_success_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 216 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let (i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336 s_337))) Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 218 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret keys_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 219 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 220 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 222 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 223 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 224 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 225 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 226 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 227 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 228 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg20) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret keys_buffer 10) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 234 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 235 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptBlock va_b0 va_s0 input key round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptBlock va_mods input key round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlock ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 193 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 214 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptBlock (va_code_AES128EncryptBlock ()) va_s0 input key round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptBlockStdcall [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlockStdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_CNil ())))) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_AES128EncryptBlock ()) (va_CCons (if win then va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ()))) (va_CNil ())))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlockStdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_AES128EncryptBlock ()) (va_pbool_and (if win then va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_ttrue ())) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlockStdcall (va_mods:va_mods_t) (win:bool) (input:quad32) (key:(seq nat32)) (input_buffer:buffer128) (output_buffer:buffer128) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlockStdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (output_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (input_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s) (fun _ -> va_get_reg64 rRdx va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 271 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret input_buffer 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 277 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret input_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 278 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun (alg_10095:Vale.AES.AES_common_s.algorithm) (key_10096:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) -> Vale.AES.AES_s.is_aes_key_LE alg_10095 key_10096) AES_128 key) (fun _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptBlock input key (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) keys_buffer) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 283 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 285 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret output_buffer 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret output_buffer 0) (va_QEmpty (()))))) (fun (va_s:va_state) va_g -> va_QEmpty (()))))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptBlockStdcall va_b0 va_s0 win input key input_buffer output_buffer keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_AES128EncryptBlockStdcall va_mods win input key input_buffer output_buffer keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlockStdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 238 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (output_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (input_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 267 column 67 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 output_buffer) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 268 column 81 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_sM) output_ptr output_buffer 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 269 column 87 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.buffer128_read output_buffer 0 (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"]
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wpProof_AES128EncryptBlockStdcall : win:bool -> input:quad32 -> key:(seq nat32) -> input_buffer:buffer128 -> output_buffer:buffer128 -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptBlockStdcall win input key input_buffer output_buffer keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptBlockStdcall win) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[]
Vale.AES.X64.AES128.va_wpProof_AES128EncryptBlockStdcall
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
win: Prims.bool -> input: Vale.X64.Decls.quad32 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> input_buffer: Vale.X64.Memory.buffer128 -> output_buffer: Vale.X64.Memory.buffer128 -> keys_buffer: Vale.X64.Memory.buffer128 -> 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)
{ "end_col": 22, "end_line": 736, "start_col": 8, "start_line": 726 }
Prims.Ghost
val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer =
false
null
false
let va_mods:va_mods_t = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Prims.nat", "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.buffer128", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_ok", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.AES.X64.AES128.va_code_AES128EncryptRound", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.Def.Types_s.quad32", "Vale.X64.Decls.va_get_xmm", "Vale.AES.AES_s.eval_rounds_def", "Vale.X64.QuickCode.quickCode", "Vale.AES.X64.AES128.va_qcode_AES128EncryptRound" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))))
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))))
[]
Vale.AES.X64.AES128.va_lemma_AES128EncryptRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> n: Prims.nat -> init: Vale.X64.Decls.quad32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_buffer: Vale.X64.Memory.buffer128 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 477, "start_col": 75, "start_line": 466 }
Prims.Ghost
val va_lemma_AES128EncryptBlock : va_b0:va_code -> va_s0:va_state -> input:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptBlock ()) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ FStar.Seq.Base.length #quad32 round_keys == 11 /\ round_keys == Vale.AES.AES_s.key_to_round_keys_LE AES_128 key /\ va_get_xmm 0 va_s0 == input /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ (forall (i:nat) . i < 11 ==> Vale.X64.Decls.buffer128_read keys_buffer i (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys i))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_lemma_AES128EncryptBlock va_b0 va_s0 input key round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptBlock va_mods input key round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlock ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 193 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 214 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
val va_lemma_AES128EncryptBlock : va_b0:va_code -> va_s0:va_state -> input:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptBlock ()) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ FStar.Seq.Base.length #quad32 round_keys == 11 /\ round_keys == Vale.AES.AES_s.key_to_round_keys_LE AES_128 key /\ va_get_xmm 0 va_s0 == input /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ (forall (i:nat) . i < 11 ==> Vale.X64.Decls.buffer128_read keys_buffer i (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys i))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) let va_lemma_AES128EncryptBlock va_b0 va_s0 input key round_keys keys_buffer =
false
null
false
let va_mods:va_mods_t = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptBlock va_mods input key round_keys keys_buffer in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_AES128EncryptBlock ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 193 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 214 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Memory.buffer128", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_ok", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.AES.X64.AES128.va_code_AES128EncryptBlock", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.Def.Types_s.quad32", "Vale.X64.Decls.va_get_xmm", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.AES.AES_common_s.AES_128", "Vale.X64.QuickCode.quickCode", "Vale.AES.X64.AES128.va_qcode_AES128EncryptBlock" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer)) //-- //-- AES128EncryptBlock [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlock () = (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CNil ()))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlock () = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and (va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound 3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and (va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound 6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and (va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound 9) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_pbool_and (va_codegen_success_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 216 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let (i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336 s_337))) Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 218 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret keys_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 219 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 220 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 222 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 223 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 224 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 225 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 226 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 227 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 228 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg20) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret keys_buffer 10) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 234 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 235 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QEmpty (()))))))))))))))))))))
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_AES128EncryptBlock : va_b0:va_code -> va_s0:va_state -> input:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptBlock ()) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ FStar.Seq.Base.length #quad32 round_keys == 11 /\ round_keys == Vale.AES.AES_s.key_to_round_keys_LE AES_128 key /\ va_get_xmm 0 va_s0 == input /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ (forall (i:nat) . i < 11 ==> Vale.X64.Decls.buffer128_read keys_buffer i (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys i))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))))
[]
Vale.AES.X64.AES128.va_lemma_AES128EncryptBlock
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> input: Vale.X64.Decls.quad32 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_buffer: Vale.X64.Memory.buffer128 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 611, "start_col": 78, "start_line": 600 }
Prims.Ghost
val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM)
val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key =
false
null
false
let va_mods:va_mods_t = [ va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem ] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem ]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Memory.nat64", "Vale.X64.Memory.nat8", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_ok", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.AES.X64.AES128.va_code_KeyExpansionRound", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.Decls.validDstAddrs128", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRdx", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.quad32", "Vale.X64.Decls.va_get_xmm", "Vale.X64.Decls.buffer128_read", "Prims.op_Addition", "Vale.Def.Types_s.quad32", "Vale.AES.AES_helpers.expand_key_128", "Vale.X64.Decls.modifies_buffer_specific128", "Vale.X64.QuickCode.quickCode", "Vale.AES.X64.AES128.va_qcode_KeyExpansionRound" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))
[]
Vale.AES.X64.AES128.va_lemma_KeyExpansionRound
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> round: Vale.X64.Memory.nat64 -> rcon: Vale.X64.Memory.nat8 -> dst: Vale.X64.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 125, "start_col": 63, "start_line": 103 }
Prims.Ghost
val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM)
val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n =
false
null
false
va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let va_old_s:va_state = va_s0 in let va_b1:va_codes = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let va_fc3, va_s3 = (if (0 < n && n <= 10) then (let va_b4 = va_get_block va_c3 in let va_s5, va_fc5 = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let va_s6, va_fc6 = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let va_s3, va_f6 = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3)) else (let va_b7 = va_get_block va_c3 in let va_s3, va_fc3 = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3))) in let va_sM, va_f3 = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[ "" ]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Memory.buffer128", "Prims.int", "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.op_AmpAmp", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Prims.list", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_tl", "Vale.AES.X64.AES128.va_lemma_KeyExpansionRound", "Vale.X64.Decls.va_hd", "Prims.op_Subtraction", "Vale.AES.AES_common_s.aes_rcon", "Vale.AES.X64.AES128.va_lemma_KeyExpansionRoundUnrolledRecursive", "Vale.X64.Decls.va_get_block", "Prims.bool", "Prims.unit", "Vale.AES.AES_helpers.expand_key_128_reveal", "Vale.X64.Decls.va_reveal_opaque", "Vale.AES.X64.AES128.va_code_KeyExpansionRoundUnrolledRecursive" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"]
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))
[ "recursion" ]
Vale.AES.X64.AES128.va_lemma_KeyExpansionRoundUnrolledRecursive
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> dst: Vale.X64.Memory.buffer128 -> n: Prims.int -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 245, "start_col": 2, "start_line": 213 }
Prims.Ghost
val va_lemma_KeyExpansion128Stdcall : va_b0:va_code -> va_s0:va_state -> win:bool -> input_key_b:buffer128 -> output_key_expansion_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansion128Stdcall win) va_s0 /\ va_get_ok va_s0 /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in aesni_enabled /\ avx_enabled /\ sse_enabled /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) key_ptr input_key_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in aesni_enabled /\ avx_enabled /\ sse_enabled /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM)
val va_lemma_KeyExpansion128Stdcall : va_b0:va_code -> va_s0:va_state -> win:bool -> input_key_b:buffer128 -> output_key_expansion_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansion128Stdcall win) va_s0 /\ va_get_ok va_s0 /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in aesni_enabled /\ avx_enabled /\ sse_enabled /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) key_ptr input_key_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in aesni_enabled /\ avx_enabled /\ sse_enabled /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))) let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b =
false
null
false
let va_mods:va_mods_t = [ va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem ] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let key_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let key_expansion_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let key_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let key_expansion_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j. {:pattern (buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))} 0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem ]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Prims.bool", "Vale.X64.Memory.buffer128", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRdx", "Vale.X64.QuickCode.va_Mod_ok", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.AES.X64.AES128.va_code_KeyExpansion128Stdcall", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.CPU_Features_s.aesni_enabled", "Vale.X64.CPU_Features_s.avx_enabled", "Vale.X64.CPU_Features_s.sse_enabled", "Vale.X64.Decls.validSrcAddrs128", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.validDstAddrs128", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat32", "Vale.Arch.Types.quad32_to_seq", "Vale.X64.Decls.buffer128_read", "Vale.X64.Decls.va_int_range", "Vale.X64.Decls.va_if", "Vale.Def.Types_s.nat64", "Vale.X64.Decls.va_get_reg64", "Prims.l_not", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRdi", "Vale.X64.Decls.modifies_buffer128", "Prims.l_Forall", "Prims.int", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Types_s.quad32", "Vale.AES.AES_s.key_to_round_keys_LE", "Vale.AES.AES_common_s.AES_128", "Prims.l_imp", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.index", "Vale.X64.QuickCode.quickCode", "Vale.AES.X64.AES128.va_qcode_KeyExpansion128Stdcall" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (())))))))))))
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_KeyExpansion128Stdcall : va_b0:va_code -> va_s0:va_state -> win:bool -> input_key_b:buffer128 -> output_key_expansion_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansion128Stdcall win) va_s0 /\ va_get_ok va_s0 /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in aesni_enabled /\ avx_enabled /\ sse_enabled /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) key_ptr input_key_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in aesni_enabled /\ avx_enabled /\ sse_enabled /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))
[]
Vale.AES.X64.AES128.va_lemma_KeyExpansion128Stdcall
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> win: Prims.bool -> input_key_b: Vale.X64.Memory.buffer128 -> output_key_expansion_b: Vale.X64.Memory.buffer128 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 403, "start_col": 88, "start_line": 366 }
Prims.Ghost
val va_lemma_AES128EncryptBlockStdcall : va_b0:va_code -> va_s0:va_state -> win:bool -> input:quad32 -> key:(seq nat32) -> input_buffer:buffer128 -> output_buffer:buffer128 -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptBlockStdcall win) va_s0 /\ va_get_ok va_s0 /\ (let (output_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (input_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in aesni_enabled /\ sse_enabled /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ Vale.X64.Decls.buffer128_read input_buffer 0 (va_get_mem_heaplet 0 va_s0) == input /\ expanded_key_ptr == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) input_ptr input_buffer 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) output_ptr output_buffer 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) expanded_key_ptr keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ (forall (i:nat) . i < 11 ==> Vale.X64.Decls.buffer128_read keys_buffer i (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) i)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (output_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (input_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 output_buffer) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_sM) output_ptr output_buffer 1 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.buffer128_read output_buffer 0 (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_lemma_AES128EncryptBlockStdcall va_b0 va_s0 win input key input_buffer output_buffer keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_AES128EncryptBlockStdcall va_mods win input key input_buffer output_buffer keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlockStdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 238 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (output_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (input_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 267 column 67 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 output_buffer) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 268 column 81 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_sM) output_ptr output_buffer 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 269 column 87 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.buffer128_read output_buffer 0 (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM)
val va_lemma_AES128EncryptBlockStdcall : va_b0:va_code -> va_s0:va_state -> win:bool -> input:quad32 -> key:(seq nat32) -> input_buffer:buffer128 -> output_buffer:buffer128 -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptBlockStdcall win) va_s0 /\ va_get_ok va_s0 /\ (let (output_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (input_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in aesni_enabled /\ sse_enabled /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ Vale.X64.Decls.buffer128_read input_buffer 0 (va_get_mem_heaplet 0 va_s0) == input /\ expanded_key_ptr == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) input_ptr input_buffer 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) output_ptr output_buffer 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) expanded_key_ptr keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ (forall (i:nat) . i < 11 ==> Vale.X64.Decls.buffer128_read keys_buffer i (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) i)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (output_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (input_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 output_buffer) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_sM) output_ptr output_buffer 1 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.buffer128_read output_buffer 0 (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) let va_lemma_AES128EncryptBlockStdcall va_b0 va_s0 win input key input_buffer output_buffer keys_buffer =
false
null
false
let va_mods:va_mods_t = [ va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_ok; va_Mod_mem ] in let va_qc = va_qcode_AES128EncryptBlockStdcall va_mods win input key input_buffer output_buffer keys_buffer in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_AES128EncryptBlockStdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 238 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let output_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let input_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let expanded_key_ptr:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 267 column 67 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 output_buffer) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 268 column 81 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_sM) output_ptr output_buffer 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 269 column 87 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.buffer128_read output_buffer 0 (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_mem_heaplet 1; va_Mod_reg64 rR8; va_Mod_ok; va_Mod_mem ]) va_sM va_s0; (va_sM, va_fM)
{ "checked_file": "Vale.AES.X64.AES128.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.AES128.fst" }
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Prims.bool", "Vale.X64.Decls.quad32", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Memory.buffer128", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR8", "Vale.X64.QuickCode.va_Mod_ok", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.AES.X64.AES128.va_code_AES128EncryptBlockStdcall", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.Decls.modifies_mem", "Vale.X64.Decls.loc_buffer", "Vale.X64.Memory.vuint128", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.validSrcAddrs128", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Secret", "Vale.Def.Types_s.quad32", "Vale.X64.Decls.buffer128_read", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.AES.AES_common_s.AES_128", "Vale.X64.Decls.va_int_range", "Vale.X64.Decls.va_if", "Vale.Def.Types_s.nat64", "Vale.X64.Decls.va_get_reg64", "Prims.l_not", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRdi", "Vale.X64.QuickCode.quickCode", "Vale.AES.X64.AES128.va_qcode_AES128EncryptBlockStdcall" ]
[]
module Vale.AES.X64.AES128 open Vale.Def.Opaque_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 20" //-- KeyExpansionRound val va_code_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansionRound round rcon = (va_Block (va_CCons (va_code_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_CCons (va_code_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_CNil ())))))))))))) val va_codegen_success_KeyExpansionRound : round:nat64 -> rcon:nat8 -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansionRound round rcon = (va_pbool_and (va_codegen_success_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_pbool_and (va_codegen_success_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret) (va_ttrue ()))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 70 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_keygen_assist (va_op_xmm_xmm 2) (va_op_xmm_xmm 1) rcon) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 71 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pshufd (va_op_xmm_xmm 2) (va_op_xmm_xmm 2) 255) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 72 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 73 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 74 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 75 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 76 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_VPslldq4 (va_op_xmm_xmm 3) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 77 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 3)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 79 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) (16 `op_Multiply` (round + 1)) Secret dst (round + 1)) (fun (va_s:va_state) _ -> let (va_arg15:Vale.Def.Types_s.nat32) = rcon in let (va_arg14:Vale.Def.Types_s.quad32) = va_get_xmm 1 va_old_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 82 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_simd_round_key va_arg14 va_arg15) (va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 83 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.expand_key_128_reveal ()) (va_QEmpty (()))))))))))))))) val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 47 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 58 column 65 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 66 column 54 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 67 column 47 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 68 column 82 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= round /\ round < 10) /\ rcon == Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ va_get_xmm 1 va_s0 == Vale.AES.AES_helpers.expand_key_128 key round /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.AES.AES_helpers.expand_key_128 key (round + 1) /\ Vale.X64.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRound : round:nat64 -> rcon:nat8 -> dst:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_KeyExpansionRound round rcon dst key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0 round rcon dst key in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRound (round:nat64) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) = (va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key)) //-- //-- KeyExpansionRoundUnrolledRecursive val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n]) [@ "opaque_to_smt"] let rec va_code_KeyExpansionRoundUnrolledRecursive n = (va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))) val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n]) [@ "opaque_to_smt"] let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n = (va_pbool_and (if (0 < n && n <= 10) then va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and (va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())) val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq nat32) -> dst:buffer128 -> n:int -> Ghost (va_state & va_fuel)(decreases %[n]) (requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))) [@"opaque_to_smt"] let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n = va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive) (va_code_KeyExpansionRoundUnrolledRecursive n); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in Vale.AES.AES_helpers.expand_key_128_reveal (); let va_b3 = va_tl va_b1 in let va_c3 = va_hd va_b1 in let (va_fc3, va_s3) = ( if (0 < n && n <= 10) then ( let va_b4 = va_get_block va_c3 in let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst (n - 1) in let va_b5 = va_tl va_b4 in let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in let va_b6 = va_tl va_b5 in let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in (va_fc3, va_s3) ) else ( let va_b7 = va_get_block va_c3 in let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in (va_fc3, va_s3) ) ) in let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in (va_sM, va_fM) [@ va_qattr] let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdx va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ (0 <= n /\ n <= 10) /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ key == Vale.Arch.Types.quad32_to_seq (va_get_xmm 1 va_s0) /\ va_get_xmm 1 va_s0 == Vale.X64.Decls.buffer128_read dst 0 (va_get_mem_heaplet 1 va_s0) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))) in va_get_ok va_sM /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg64 rRdx va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer128 dst (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_xmm 1 va_sM == Vale.X64.Decls.buffer128_read dst n (va_get_mem_heaplet 1 va_sM) /\ (forall j . {:pattern(buffer128_read dst j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= n ==> Vale.X64.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_helpers.expand_key_128 key j) ==> va_k va_sM (()))) val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n: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_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) : (va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) = (va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_KeyExpansionRoundUnrolledRecursive key dst n) (va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n)) //-- //-- KeyExpansion128Stdcall [@ "opaque_to_smt" va_qattr] let va_code_KeyExpansion128Stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_CNil ())))) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_KeyExpansion128Stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (win:bool) (input_key_b:buffer128) (output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s)) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 143 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 145 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRcx) 0 Secret input_key_b 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 149 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rRdi) 0 Secret input_key_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 150 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rRsi)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 153 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdx) (va_op_xmm_xmm 1) 0 Secret output_key_expansion_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 154 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun (va_s:va_state) _ -> let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 155 column 25 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_helpers.lemma_expand_key_128 va_arg18 11) (va_QLemma va_range1 "***** PRECONDITION NOT MET AT line 156 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" true (fun _ -> va_reveal_eq (`%key_to_round_keys_LE) key_to_round_keys_LE key_to_round_keys_LE) (fun _ -> va_reveal_opaque (`%key_to_round_keys_LE) key_to_round_keys_LE) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 3) (va_op_xmm_xmm 3)) (va_QEmpty (()))))))))))) [@"opaque_to_smt"] let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 win input_key_b output_key_expansion_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_KeyExpansion128Stdcall va_mods win input_key_b output_key_expansion_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 119 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 135 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (aesni_enabled /\ avx_enabled /\ sse_enabled) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 136 column 76 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) key_ptr input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 137 column 98 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) key_expansion_ptr output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (key_expansion_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (key:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = Vale.Arch.Types.quad32_to_seq (Vale.X64.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0)) in label va_range1 "***** POSTCONDITION NOT MET AT line 139 column 70 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (Vale.X64.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 141 column 109 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (forall j . {:pattern(buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM))}0 <= j /\ j <= 10 ==> Vale.X64.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) j))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_KeyExpansion128Stdcall win input_key_b output_key_expansion_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall win) va_s0 win input_key_b output_key_expansion_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_mem_heaplet 1; va_Mod_reg64 rRdx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptRound val va_code_AES128EncryptRound : n:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptRound n = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_CCons (va_code_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CNil ())))) val va_codegen_success_AES128EncryptRound : n:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptRound n = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret) (va_pbool_and (va_codegen_success_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_ttrue ()))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (va_arg5:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 188 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg5) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 189 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` n) Secret keys_buffer n) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 190 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QEmpty (())))))) val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0)))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 168 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 53 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (aesni_enabled /\ sse_enabled) /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_xmm 0 va_s0 == Vale.AES.AES_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg64 rR8 va_s0 == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR8 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_xmm0:quad32) (va_x_xmm2:quad32) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 0 va_x_xmm0 va_s0)) in va_get_ok va_sM /\ va_get_xmm 0 va_sM == Vale.AES.AES_s.eval_rounds_def init round_keys n ==> va_k va_sM (()))) val va_wpProof_AES128EncryptRound : n:nat -> init:quad32 -> round_keys:(seq quad32) -> keys_buffer:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_AES128EncryptRound (n:nat) (init:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) = (va_QProc (va_code_AES128EncryptRound n) ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) (va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init round_keys keys_buffer)) //-- //-- AES128EncryptBlock [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlock () = (va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons (va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons (va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons (va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons (va_code_AES128EncryptRound 9) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_CCons (va_code_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_CCons (va_code_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_CNil ()))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlock () = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and (va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound 3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and (va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound 6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and (va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound 9) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret) (va_pbool_and (va_codegen_success_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 216 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let (i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336 s_337))) Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 218 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) 0 Secret keys_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 219 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 220 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 222 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 223 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 224 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 225 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 226 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 227 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 228 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (fun (va_s:va_state) _ -> let (va_arg20:Vale.Def.Types_s.quad32) = va_get_xmm 0 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 229 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.commute_sub_bytes_shift_rows va_arg20) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 2) (va_op_reg_opr64_reg64 rR8) (16 `op_Multiply` 10) Secret keys_buffer 10) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 19 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AESNI_enc_last (va_op_xmm_xmm 0) (va_op_xmm_xmm 2)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 234 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 2) (va_op_xmm_xmm 2)) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 235 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QEmpty (())))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_AES128EncryptBlock va_b0 va_s0 input key round_keys keys_buffer = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok] in let va_qc = va_qcode_AES128EncryptBlock va_mods input key round_keys keys_buffer in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlock ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 193 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_ok va_sM) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 214 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_get_xmm 0 va_sM == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input)) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0; va_Mod_ok]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k = let (va_sM, va_f0) = va_lemma_AES128EncryptBlock (va_code_AES128EncryptBlock ()) va_s0 input key round_keys keys_buffer in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_xmm 2; va_Mod_xmm 0]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AES128EncryptBlockStdcall [@ "opaque_to_smt" va_qattr] let va_code_AES128EncryptBlockStdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_CNil ())))) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_AES128EncryptBlock ()) (va_CCons (if win then va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ())) else va_Block (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_CNil ()))) (va_CNil ())))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_AES128EncryptBlockStdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_ttrue ()))) (va_pbool_and (va_codegen_success_AES128EncryptBlock ()) (va_pbool_and (if win then va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret) (va_ttrue ()) else va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret) (va_ttrue ())) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_AES128EncryptBlockStdcall (va_mods:va_mods_t) (win:bool) (input:quad32) (key:(seq nat32)) (input_buffer:buffer128) (output_buffer:buffer128) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlockStdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (output_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (input_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s) (fun _ -> va_get_reg64 rRdx va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 271 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRdx) 0 Secret input_buffer 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 277 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRsi) 0 Secret input_buffer 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 278 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRdx)) (va_QEmpty (())))))) (fun (va_s:va_state) va_g -> va_qAssertSquash va_range1 "***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" ((fun (alg_10095:Vale.AES.AES_common_s.algorithm) (key_10096:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) -> Vale.AES.AES_s.is_aes_key_LE alg_10095 key_10096) AES_128 key) (fun _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 281 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_AES128EncryptBlock input key (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) keys_buffer) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 283 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 285 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRcx) (va_op_xmm_xmm 0) 0 Secret output_buffer 0) (va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 289 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.AES128.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 1) (va_op_reg_opr64_reg64 rRdi) (va_op_xmm_xmm 0) 0 Secret output_buffer 0) (va_QEmpty (()))))) (fun (va_s:va_state) va_g -> va_QEmpty (()))))))) [@"opaque_to_smt"]
false
false
Vale.AES.X64.AES128.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_lemma_AES128EncryptBlockStdcall : va_b0:va_code -> va_s0:va_state -> win:bool -> input:quad32 -> key:(seq nat32) -> input_buffer:buffer128 -> output_buffer:buffer128 -> keys_buffer:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES128EncryptBlockStdcall win) va_s0 /\ va_get_ok va_s0 /\ (let (output_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (input_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in aesni_enabled /\ sse_enabled /\ Vale.AES.AES_s.is_aes_key_LE AES_128 key /\ Vale.X64.Decls.buffer128_read input_buffer 0 (va_get_mem_heaplet 0 va_s0) == input /\ expanded_key_ptr == Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) input_ptr input_buffer 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) output_ptr output_buffer 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) expanded_key_ptr keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ (forall (i:nat) . i < 11 ==> Vale.X64.Decls.buffer128_read keys_buffer i (va_get_mem_heaplet 0 va_s0) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_s.key_to_round_keys_LE AES_128 key) i)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (output_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (input_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (expanded_key_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 output_buffer) (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_sM) output_ptr output_buffer 1 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.buffer128_read output_buffer 0 (va_get_mem_heaplet 1 va_sM) == Vale.AES.AES_s.aes_encrypt_LE AES_128 key input) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_xmm 2 va_sM (va_update_xmm 0 va_sM (va_update_mem_heaplet 1 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))
[]
Vale.AES.X64.AES128.va_lemma_AES128EncryptBlockStdcall
{ "file_name": "obj/Vale.AES.X64.AES128.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> win: Prims.bool -> input: Vale.X64.Decls.quad32 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> input_buffer: Vale.X64.Memory.buffer128 -> output_buffer: Vale.X64.Memory.buffer128 -> keys_buffer: Vale.X64.Memory.buffer128 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 16, "end_line": 721, "start_col": 15, "start_line": 696 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gf8 = gf U8 irred
let gf8 =
false
null
false
gf U8 irred
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.GaloisField.gf", "Lib.IntTypes.U8", "Spec.AES.irred" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *)
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gf8 : Spec.GaloisField.field
[]
Spec.AES.gf8
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.GaloisField.field
{ "end_col": 21, "end_line": 16, "start_col": 10, "start_line": 16 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let to_elem = to_felem #gf8
let to_elem =
false
null
false
to_felem #gf8
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.GaloisField.to_felem", "Spec.AES.gf8" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val to_elem : n: Prims.nat{n <= Lib.IntTypes.maxint (GF?.t Spec.AES.gf8)} -> Spec.GaloisField.felem Spec.AES.gf8
[]
Spec.AES.to_elem
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat{n <= Lib.IntTypes.maxint (GF?.t Spec.AES.gf8)} -> Spec.GaloisField.felem Spec.AES.gf8
{ "end_col": 27, "end_line": 18, "start_col": 14, "start_line": 18 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y)
let op_Hat_Dot x y =
false
null
false
normalize_term (logxor #U8 #SEC x y)
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.Pervasives.normalize_term", "Lib.IntTypes.logxor" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *)
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Hat_Dot : x: Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC -> y: Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC -> Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC
[]
Spec.AES.op_Hat_Dot
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC -> y: Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC -> Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC
{ "end_col": 53, "end_line": 25, "start_col": 17, "start_line": 25 }
Prims.Tot
val addRoundKey (key state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let addRoundKey (key:block) (state:block) : Tot block = xor_block state key
val addRoundKey (key state: block) : Tot block let addRoundKey (key state: block) : Tot block =
false
null
false
xor_block state key
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Spec.AES.xor_block" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val addRoundKey (key state: block) : Tot block
[]
Spec.AES.addRoundKey
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: Spec.AES.block -> state: Spec.AES.block -> Spec.AES.block
{ "end_col": 21, "end_line": 155, "start_col": 2, "start_line": 155 }
Prims.Tot
val aes_dec_last (key state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state
val aes_dec_last (key state: block) : Tot block let aes_dec_last (key state: block) : Tot block =
false
null
false
let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Spec.AES.addRoundKey", "Spec.AES.inv_shiftRows", "Spec.AES.inv_subBytes" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_dec_last (key state: block) : Tot block
[]
Spec.AES.aes_dec_last
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: Spec.AES.block -> state: Spec.AES.block -> Spec.AES.block
{ "end_col": 7, "end_line": 181, "start_col": 56, "start_line": 177 }
Prims.Tot
val mix4 (s0 s1 s2 s3: elem) : Tot elem
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3
val mix4 (s0 s1 s2 s3: elem) : Tot elem let mix4 (s0 s1 s2 s3: elem) : Tot elem =
false
null
false
(((s0 `fmul` two) `fadd` (s1 `fmul` three)) `fadd` s2) `fadd` s3
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.elem", "Spec.GaloisField.fadd", "Spec.AES.gf8", "Spec.GaloisField.fmul", "Spec.AES.two", "Spec.AES.three" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mix4 (s0 s1 s2 s3: elem) : Tot elem
[]
Spec.AES.mix4
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s0: Spec.AES.elem -> s1: Spec.AES.elem -> s2: Spec.AES.elem -> s3: Spec.AES.elem -> Spec.AES.elem
{ "end_col": 14, "end_line": 99, "start_col": 2, "start_line": 97 }
Prims.Tot
val aes_ctr_current_key_block (v: variant) (st: aes_ctr_state v) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_ctr_current_key_block (v:variant) (st:aes_ctr_state v) : Tot block = aes_encrypt_block v st.key_ex st.block
val aes_ctr_current_key_block (v: variant) (st: aes_ctr_state v) : Tot block let aes_ctr_current_key_block (v: variant) (st: aes_ctr_state v) : Tot block =
false
null
false
aes_encrypt_block v st.key_ex st.block
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Spec.AES.aes_ctr_state", "Spec.AES.aes_encrypt_block", "Spec.AES.__proj__Mkaes_ctr_state__item__key_ex", "Spec.AES.__proj__Mkaes_ctr_state__item__block", "Spec.AES.block" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state let aes_decrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_dec_rounds v k state in let state = aes_dec_last kn state in state let aes_ctr_key_block (v:variant) (k:aes_xkey v) (n:lbytes 12) (c:size_nat) : Tot block = let ctrby = nat_to_bytes_be 4 c in let input = create 16 (u8 0) in let input = repeati #(lbytes 16) 12 (fun i b -> b.[i] <- n.[i]) input in let input = repeati #(lbytes 16) 4 (fun i b -> b.[12+i] <- (Seq.index ctrby i)) input in aes_encrypt_block v k input noeq type aes_ctr_state (v:variant) = { key_ex: lbytes ((num_rounds v + 1) * 16); block: lbytes 16; } let aes_ctr_add_counter (v:variant) (st:aes_ctr_state v) (incr:size_nat) : Tot (aes_ctr_state v) = let n = nat_from_bytes_be st.block in let n' = (n + incr) % pow2 128 in let nblock' = nat_to_bytes_be 16 n' in {st with block = nblock'} let aes_ctr_init (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) (c0:size_nat) : Tot (aes_ctr_state v) = let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[i] <- n.[i]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input} in aes_ctr_add_counter v st0 c0
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_ctr_current_key_block (v: variant) (st: aes_ctr_state v) : Tot block
[]
Spec.AES.aes_ctr_current_key_block
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> st: Spec.AES.aes_ctr_state v -> Spec.AES.block
{ "end_col": 40, "end_line": 355, "start_col": 2, "start_line": 355 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes128_ctr_key_block1 key n_len n = aes_ctr_key_block0 AES128 key n_len n
let aes128_ctr_key_block1 key n_len n =
false
null
false
aes_ctr_key_block0 AES128 key n_len n
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.aes_key", "Spec.AES.AES128", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.ByteSequence.lbytes", "Spec.AES.aes_ctr_key_block0", "Spec.AES.block" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state let aes_decrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_dec_rounds v k state in let state = aes_dec_last kn state in state let aes_ctr_key_block (v:variant) (k:aes_xkey v) (n:lbytes 12) (c:size_nat) : Tot block = let ctrby = nat_to_bytes_be 4 c in let input = create 16 (u8 0) in let input = repeati #(lbytes 16) 12 (fun i b -> b.[i] <- n.[i]) input in let input = repeati #(lbytes 16) 4 (fun i b -> b.[12+i] <- (Seq.index ctrby i)) input in aes_encrypt_block v k input noeq type aes_ctr_state (v:variant) = { key_ex: lbytes ((num_rounds v + 1) * 16); block: lbytes 16; } let aes_ctr_add_counter (v:variant) (st:aes_ctr_state v) (incr:size_nat) : Tot (aes_ctr_state v) = let n = nat_from_bytes_be st.block in let n' = (n + incr) % pow2 128 in let nblock' = nat_to_bytes_be 16 n' in {st with block = nblock'} let aes_ctr_init (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) (c0:size_nat) : Tot (aes_ctr_state v) = let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[i] <- n.[i]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input} in aes_ctr_add_counter v st0 c0 let aes_ctr_current_key_block (v:variant) (st:aes_ctr_state v) : Tot block = aes_encrypt_block v st.key_ex st.block let aes_ctr_key_block0 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 0 in aes_ctr_current_key_block v st let aes_ctr_key_block1 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 1 in aes_ctr_current_key_block v st let aes_ctr_encrypt_block (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (b:block) : Tot block = let st = aes_ctr_add_counter v st0 incr in let kb = aes_ctr_current_key_block v st in map2 (^.) b kb let aes_ctr_encrypt_last (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (len:size_nat{len < 16}) (b:lbytes len): Tot (lbytes len) = let plain = create 16 (u8 0) in let plain = update_sub plain 0 (length b) b in let cipher = aes_ctr_encrypt_block v st0 incr plain in sub cipher 0 (length b) val aes_ctr_encrypt_stream: v:variant -> st:aes_ctr_state v -> msg:bytes{length msg / 16 <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg}) let aes_ctr_encrypt_stream v st msg = map_blocks 16 msg (aes_ctr_encrypt_block v st) (aes_ctr_encrypt_last v st) val aes_ctr_encrypt_bytes: v:variant -> key:aes_key v -> n_len:size_nat{n_len <= 16} -> nonce:lbytes n_len -> c:size_nat -> msg:bytes{length msg / 16 + c <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg}) let aes_ctr_encrypt_bytes v key n_len nonce ctr0 msg = let st0 = aes_ctr_init v key n_len nonce ctr0 in aes_ctr_encrypt_stream v st0 msg let aes128_ctr_encrypt_bytes key n_len nonce ctr0 msg = aes_ctr_encrypt_bytes AES128 key n_len nonce ctr0 msg let aes128_ctr_key_block0 key n_len n = aes_ctr_key_block0 AES128 key n_len n
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes128_ctr_key_block1 : key: Spec.AES.aes_key Spec.AES.AES128 -> n_len: Lib.IntTypes.size_nat{n_len <= 16} -> n: Lib.ByteSequence.lbytes n_len -> Spec.AES.block
[]
Spec.AES.aes128_ctr_key_block1
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: Spec.AES.aes_key Spec.AES.AES128 -> n_len: Lib.IntTypes.size_nat{n_len <= 16} -> n: Lib.ByteSequence.lbytes n_len -> Spec.AES.block
{ "end_col": 39, "end_line": 422, "start_col": 2, "start_line": 422 }
Prims.Tot
val aes_enc (key state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state
val aes_enc (key state: block) : Tot block let aes_enc (key state: block) : Tot block =
false
null
false
let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Spec.AES.addRoundKey", "Spec.AES.mixColumns", "Spec.AES.shiftRows", "Spec.AES.subBytes" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_enc (key state: block) : Tot block
[]
Spec.AES.aes_enc
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: Spec.AES.block -> state: Spec.AES.block -> Spec.AES.block
{ "end_col": 7, "end_line": 162, "start_col": 51, "start_line": 157 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes128_ctr_key_block0 key n_len n = aes_ctr_key_block0 AES128 key n_len n
let aes128_ctr_key_block0 key n_len n =
false
null
false
aes_ctr_key_block0 AES128 key n_len n
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.aes_key", "Spec.AES.AES128", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.ByteSequence.lbytes", "Spec.AES.aes_ctr_key_block0", "Spec.AES.block" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state let aes_decrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_dec_rounds v k state in let state = aes_dec_last kn state in state let aes_ctr_key_block (v:variant) (k:aes_xkey v) (n:lbytes 12) (c:size_nat) : Tot block = let ctrby = nat_to_bytes_be 4 c in let input = create 16 (u8 0) in let input = repeati #(lbytes 16) 12 (fun i b -> b.[i] <- n.[i]) input in let input = repeati #(lbytes 16) 4 (fun i b -> b.[12+i] <- (Seq.index ctrby i)) input in aes_encrypt_block v k input noeq type aes_ctr_state (v:variant) = { key_ex: lbytes ((num_rounds v + 1) * 16); block: lbytes 16; } let aes_ctr_add_counter (v:variant) (st:aes_ctr_state v) (incr:size_nat) : Tot (aes_ctr_state v) = let n = nat_from_bytes_be st.block in let n' = (n + incr) % pow2 128 in let nblock' = nat_to_bytes_be 16 n' in {st with block = nblock'} let aes_ctr_init (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) (c0:size_nat) : Tot (aes_ctr_state v) = let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[i] <- n.[i]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input} in aes_ctr_add_counter v st0 c0 let aes_ctr_current_key_block (v:variant) (st:aes_ctr_state v) : Tot block = aes_encrypt_block v st.key_ex st.block let aes_ctr_key_block0 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 0 in aes_ctr_current_key_block v st let aes_ctr_key_block1 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 1 in aes_ctr_current_key_block v st let aes_ctr_encrypt_block (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (b:block) : Tot block = let st = aes_ctr_add_counter v st0 incr in let kb = aes_ctr_current_key_block v st in map2 (^.) b kb let aes_ctr_encrypt_last (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (len:size_nat{len < 16}) (b:lbytes len): Tot (lbytes len) = let plain = create 16 (u8 0) in let plain = update_sub plain 0 (length b) b in let cipher = aes_ctr_encrypt_block v st0 incr plain in sub cipher 0 (length b) val aes_ctr_encrypt_stream: v:variant -> st:aes_ctr_state v -> msg:bytes{length msg / 16 <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg}) let aes_ctr_encrypt_stream v st msg = map_blocks 16 msg (aes_ctr_encrypt_block v st) (aes_ctr_encrypt_last v st) val aes_ctr_encrypt_bytes: v:variant -> key:aes_key v -> n_len:size_nat{n_len <= 16} -> nonce:lbytes n_len -> c:size_nat -> msg:bytes{length msg / 16 + c <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg}) let aes_ctr_encrypt_bytes v key n_len nonce ctr0 msg = let st0 = aes_ctr_init v key n_len nonce ctr0 in aes_ctr_encrypt_stream v st0 msg let aes128_ctr_encrypt_bytes key n_len nonce ctr0 msg = aes_ctr_encrypt_bytes AES128 key n_len nonce ctr0 msg
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes128_ctr_key_block0 : key: Spec.AES.aes_key Spec.AES.AES128 -> n_len: Lib.IntTypes.size_nat{n_len <= 16} -> n: Lib.ByteSequence.lbytes n_len -> Spec.AES.block
[]
Spec.AES.aes128_ctr_key_block0
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: Spec.AES.aes_key Spec.AES.AES128 -> n_len: Lib.IntTypes.size_nat{n_len <= 16} -> n: Lib.ByteSequence.lbytes n_len -> Spec.AES.block
{ "end_col": 39, "end_line": 419, "start_col": 2, "start_line": 419 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes128_ctr_encrypt_bytes key n_len nonce ctr0 msg = aes_ctr_encrypt_bytes AES128 key n_len nonce ctr0 msg
let aes128_ctr_encrypt_bytes key n_len nonce ctr0 msg =
false
null
false
aes_ctr_encrypt_bytes AES128 key n_len nonce ctr0 msg
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.aes_key", "Spec.AES.AES128", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.ByteSequence.lbytes", "Lib.ByteSequence.bytes", "Prims.op_Addition", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.max_size_t", "Spec.AES.aes_ctr_encrypt_bytes", "Lib.Sequence.seq", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.nat" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state let aes_decrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_dec_rounds v k state in let state = aes_dec_last kn state in state let aes_ctr_key_block (v:variant) (k:aes_xkey v) (n:lbytes 12) (c:size_nat) : Tot block = let ctrby = nat_to_bytes_be 4 c in let input = create 16 (u8 0) in let input = repeati #(lbytes 16) 12 (fun i b -> b.[i] <- n.[i]) input in let input = repeati #(lbytes 16) 4 (fun i b -> b.[12+i] <- (Seq.index ctrby i)) input in aes_encrypt_block v k input noeq type aes_ctr_state (v:variant) = { key_ex: lbytes ((num_rounds v + 1) * 16); block: lbytes 16; } let aes_ctr_add_counter (v:variant) (st:aes_ctr_state v) (incr:size_nat) : Tot (aes_ctr_state v) = let n = nat_from_bytes_be st.block in let n' = (n + incr) % pow2 128 in let nblock' = nat_to_bytes_be 16 n' in {st with block = nblock'} let aes_ctr_init (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) (c0:size_nat) : Tot (aes_ctr_state v) = let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[i] <- n.[i]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input} in aes_ctr_add_counter v st0 c0 let aes_ctr_current_key_block (v:variant) (st:aes_ctr_state v) : Tot block = aes_encrypt_block v st.key_ex st.block let aes_ctr_key_block0 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 0 in aes_ctr_current_key_block v st let aes_ctr_key_block1 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 1 in aes_ctr_current_key_block v st let aes_ctr_encrypt_block (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (b:block) : Tot block = let st = aes_ctr_add_counter v st0 incr in let kb = aes_ctr_current_key_block v st in map2 (^.) b kb let aes_ctr_encrypt_last (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (len:size_nat{len < 16}) (b:lbytes len): Tot (lbytes len) = let plain = create 16 (u8 0) in let plain = update_sub plain 0 (length b) b in let cipher = aes_ctr_encrypt_block v st0 incr plain in sub cipher 0 (length b) val aes_ctr_encrypt_stream: v:variant -> st:aes_ctr_state v -> msg:bytes{length msg / 16 <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg}) let aes_ctr_encrypt_stream v st msg = map_blocks 16 msg (aes_ctr_encrypt_block v st) (aes_ctr_encrypt_last v st) val aes_ctr_encrypt_bytes: v:variant -> key:aes_key v -> n_len:size_nat{n_len <= 16} -> nonce:lbytes n_len -> c:size_nat -> msg:bytes{length msg / 16 + c <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg}) let aes_ctr_encrypt_bytes v key n_len nonce ctr0 msg = let st0 = aes_ctr_init v key n_len nonce ctr0 in aes_ctr_encrypt_stream v st0 msg
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes128_ctr_encrypt_bytes : key: Spec.AES.aes_key Spec.AES.AES128 -> n_len: Lib.IntTypes.size_nat{n_len <= 16} -> nonce: Lib.ByteSequence.lbytes n_len -> ctr0: Lib.IntTypes.size_nat -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length msg / 16 + ctr0 <= Lib.IntTypes.max_size_t} -> ciphertext: Lib.Sequence.seq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) {Lib.Sequence.length ciphertext == Lib.Sequence.length msg}
[]
Spec.AES.aes128_ctr_encrypt_bytes
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: Spec.AES.aes_key Spec.AES.AES128 -> n_len: Lib.IntTypes.size_nat{n_len <= 16} -> nonce: Lib.ByteSequence.lbytes n_len -> ctr0: Lib.IntTypes.size_nat -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length msg / 16 + ctr0 <= Lib.IntTypes.max_size_t} -> ciphertext: Lib.Sequence.seq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) {Lib.Sequence.length ciphertext == Lib.Sequence.length msg}
{ "end_col": 55, "end_line": 416, "start_col": 2, "start_line": 416 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes256_ctr_encrypt_bytes key n_len nonce ctr0 msg = aes_ctr_encrypt_bytes AES256 key n_len nonce ctr0 msg
let aes256_ctr_encrypt_bytes key n_len nonce ctr0 msg =
false
null
false
aes_ctr_encrypt_bytes AES256 key n_len nonce ctr0 msg
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.aes_key", "Spec.AES.AES256", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.ByteSequence.lbytes", "Lib.ByteSequence.bytes", "Prims.op_Addition", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.max_size_t", "Spec.AES.aes_ctr_encrypt_bytes", "Lib.Sequence.seq", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.nat" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state let aes_decrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_dec_rounds v k state in let state = aes_dec_last kn state in state let aes_ctr_key_block (v:variant) (k:aes_xkey v) (n:lbytes 12) (c:size_nat) : Tot block = let ctrby = nat_to_bytes_be 4 c in let input = create 16 (u8 0) in let input = repeati #(lbytes 16) 12 (fun i b -> b.[i] <- n.[i]) input in let input = repeati #(lbytes 16) 4 (fun i b -> b.[12+i] <- (Seq.index ctrby i)) input in aes_encrypt_block v k input noeq type aes_ctr_state (v:variant) = { key_ex: lbytes ((num_rounds v + 1) * 16); block: lbytes 16; } let aes_ctr_add_counter (v:variant) (st:aes_ctr_state v) (incr:size_nat) : Tot (aes_ctr_state v) = let n = nat_from_bytes_be st.block in let n' = (n + incr) % pow2 128 in let nblock' = nat_to_bytes_be 16 n' in {st with block = nblock'} let aes_ctr_init (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) (c0:size_nat) : Tot (aes_ctr_state v) = let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[i] <- n.[i]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input} in aes_ctr_add_counter v st0 c0 let aes_ctr_current_key_block (v:variant) (st:aes_ctr_state v) : Tot block = aes_encrypt_block v st.key_ex st.block let aes_ctr_key_block0 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 0 in aes_ctr_current_key_block v st let aes_ctr_key_block1 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 1 in aes_ctr_current_key_block v st let aes_ctr_encrypt_block (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (b:block) : Tot block = let st = aes_ctr_add_counter v st0 incr in let kb = aes_ctr_current_key_block v st in map2 (^.) b kb let aes_ctr_encrypt_last (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (len:size_nat{len < 16}) (b:lbytes len): Tot (lbytes len) = let plain = create 16 (u8 0) in let plain = update_sub plain 0 (length b) b in let cipher = aes_ctr_encrypt_block v st0 incr plain in sub cipher 0 (length b) val aes_ctr_encrypt_stream: v:variant -> st:aes_ctr_state v -> msg:bytes{length msg / 16 <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg}) let aes_ctr_encrypt_stream v st msg = map_blocks 16 msg (aes_ctr_encrypt_block v st) (aes_ctr_encrypt_last v st) val aes_ctr_encrypt_bytes: v:variant -> key:aes_key v -> n_len:size_nat{n_len <= 16} -> nonce:lbytes n_len -> c:size_nat -> msg:bytes{length msg / 16 + c <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg}) let aes_ctr_encrypt_bytes v key n_len nonce ctr0 msg = let st0 = aes_ctr_init v key n_len nonce ctr0 in aes_ctr_encrypt_stream v st0 msg let aes128_ctr_encrypt_bytes key n_len nonce ctr0 msg = aes_ctr_encrypt_bytes AES128 key n_len nonce ctr0 msg let aes128_ctr_key_block0 key n_len n = aes_ctr_key_block0 AES128 key n_len n let aes128_ctr_key_block1 key n_len n = aes_ctr_key_block0 AES128 key n_len n
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes256_ctr_encrypt_bytes : key: Spec.AES.aes_key Spec.AES.AES256 -> n_len: Lib.IntTypes.size_nat{n_len <= 16} -> nonce: Lib.ByteSequence.lbytes n_len -> ctr0: Lib.IntTypes.size_nat -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length msg / 16 + ctr0 <= Lib.IntTypes.max_size_t} -> ciphertext: Lib.Sequence.seq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) {Lib.Sequence.length ciphertext == Lib.Sequence.length msg}
[]
Spec.AES.aes256_ctr_encrypt_bytes
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: Spec.AES.aes_key Spec.AES.AES256 -> n_len: Lib.IntTypes.size_nat{n_len <= 16} -> nonce: Lib.ByteSequence.lbytes n_len -> ctr0: Lib.IntTypes.size_nat -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length msg / 16 + ctr0 <= Lib.IntTypes.max_size_t} -> ciphertext: Lib.Sequence.seq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC) {Lib.Sequence.length ciphertext == Lib.Sequence.length msg}
{ "end_col": 55, "end_line": 425, "start_col": 2, "start_line": 425 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let elem = felem gf8
let elem =
false
null
false
felem gf8
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.GaloisField.felem", "Spec.AES.gf8" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val elem : Type0
[]
Spec.AES.elem
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 20, "end_line": 17, "start_col": 11, "start_line": 17 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y)
let op_Less_Less_Less_Dot x y =
false
null
false
normalize_term (rotate_left #U8 #SEC x y)
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.b2t", "Lib.IntTypes.unsigned", "Lib.IntTypes.rotval", "FStar.Pervasives.normalize_term", "Lib.IntTypes.rotate_left" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Less_Less_Less_Dot : x: a: Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC {Lib.IntTypes.unsigned Lib.IntTypes.U8} -> y: Lib.IntTypes.rotval Lib.IntTypes.U8 -> Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC
[]
Spec.AES.op_Less_Less_Less_Dot
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: a: Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC {Lib.IntTypes.unsigned Lib.IntTypes.U8} -> y: Lib.IntTypes.rotval Lib.IntTypes.U8 -> Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC
{ "end_col": 60, "end_line": 24, "start_col": 19, "start_line": 24 }
Prims.Tot
val aes_enc_last (key state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state
val aes_enc_last (key state: block) : Tot block let aes_enc_last (key state: block) : Tot block =
false
null
false
let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Spec.AES.addRoundKey", "Spec.AES.shiftRows", "Spec.AES.subBytes" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_enc_last (key state: block) : Tot block
[]
Spec.AES.aes_enc_last
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: Spec.AES.block -> state: Spec.AES.block -> Spec.AES.block
{ "end_col": 7, "end_line": 168, "start_col": 56, "start_line": 164 }
Prims.Tot
val aes_dec (key state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state
val aes_dec (key state: block) : Tot block let aes_dec (key state: block) : Tot block =
false
null
false
let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Spec.AES.addRoundKey", "Spec.AES.inv_mixColumns", "Spec.AES.inv_shiftRows", "Spec.AES.inv_subBytes" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_dec (key state: block) : Tot block
[]
Spec.AES.aes_dec
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key: Spec.AES.block -> state: Spec.AES.block -> Spec.AES.block
{ "end_col": 7, "end_line": 175, "start_col": 51, "start_line": 170 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let three = to_elem 3
let three =
false
null
false
to_elem 3
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.to_elem" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val three : Spec.GaloisField.felem Spec.AES.gf8
[]
Spec.AES.three
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.GaloisField.felem Spec.AES.gf8
{ "end_col": 21, "end_line": 21, "start_col": 12, "start_line": 21 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let irred = u8 0x1b
let irred =
false
null
false
u8 0x1b
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Lib.IntTypes.u8" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val irred : u0: Lib.IntTypes.uint8{Lib.IntTypes.v u0 == 0x1b}
[]
Spec.AES.irred
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
u0: Lib.IntTypes.uint8{Lib.IntTypes.v u0 == 0x1b}
{ "end_col": 19, "end_line": 15, "start_col": 12, "start_line": 15 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let two = to_elem 2
let two =
false
null
false
to_elem 2
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.to_elem" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val two : Spec.GaloisField.felem Spec.AES.gf8
[]
Spec.AES.two
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.GaloisField.felem Spec.AES.gf8
{ "end_col": 19, "end_line": 20, "start_col": 10, "start_line": 20 }
Prims.Tot
val aes_key_expansion (v: variant) (key: aes_key v) : aes_xkey v
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key
val aes_key_expansion (v: variant) (key: aes_key v) : aes_xkey v let aes_key_expansion (v: variant) (key: aes_key v) : aes_xkey v =
false
null
false
match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Spec.AES.aes_key", "Spec.AES.aes128_key_expansion", "Spec.AES.aes256_key_expansion", "Spec.AES.aes_xkey" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_key_expansion (v: variant) (key: aes_key v) : aes_xkey v
[]
Spec.AES.aes_key_expansion
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> key: Spec.AES.aes_key v -> Spec.AES.aes_xkey v
{ "end_col": 38, "end_line": 287, "start_col": 2, "start_line": 285 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32
let key_size (v: variant) =
false
null
false
match v with | AES128 -> 16 | AES256 -> 32
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Prims.int" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val key_size : v: Spec.AES.variant -> Prims.int
[]
Spec.AES.key_size
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> Prims.int
{ "end_col": 16, "end_line": 41, "start_col": 2, "start_line": 39 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14
let num_rounds (v: variant) =
false
null
false
match v with | AES128 -> 10 | AES256 -> 14
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Prims.int" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val num_rounds : v: Spec.AES.variant -> Prims.int
[]
Spec.AES.num_rounds
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> Prims.int
{ "end_col": 16, "end_line": 36, "start_col": 2, "start_line": 34 }
Prims.Tot
val shiftRows (state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state
val shiftRows (state: block) : Tot block let shiftRows (state: block) : Tot block =
false
null
false
let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Spec.AES.shiftRow" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val shiftRows (state: block) : Tot block
[]
Spec.AES.shiftRows
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
state: Spec.AES.block -> Spec.AES.block
{ "end_col": 7, "end_line": 88, "start_col": 42, "start_line": 84 }
Prims.Tot
val inv_mix4 (s0 s1 s2 s3: elem) : Tot elem
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9)
val inv_mix4 (s0 s1 s2 s3: elem) : Tot elem let inv_mix4 (s0 s1 s2 s3: elem) : Tot elem =
false
null
false
(((s0 `fmul` (to_elem 14)) `fadd` (s1 `fmul` (to_elem 11))) `fadd` (s2 `fmul` (to_elem 13))) `fadd` (s3 `fmul` (to_elem 9))
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.elem", "Spec.GaloisField.fadd", "Spec.AES.gf8", "Spec.GaloisField.fmul", "Spec.AES.to_elem" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14)
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val inv_mix4 (s0 s1 s2 s3: elem) : Tot elem
[]
Spec.AES.inv_mix4
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s0: Spec.AES.elem -> s1: Spec.AES.elem -> s2: Spec.AES.elem -> s3: Spec.AES.elem -> Spec.AES.elem
{ "end_col": 23, "end_line": 111, "start_col": 2, "start_line": 108 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16)
let aes_ikey (v: variant) =
false
null
false
lseq elem ((num_rounds v - 1) * 16)
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Lib.Sequence.lseq", "Spec.AES.elem", "FStar.Mul.op_Star", "Prims.op_Subtraction", "Spec.AES.num_rounds" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v)
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_ikey : v: Spec.AES.variant -> Type0
[]
Spec.AES.aes_ikey
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> Type0
{ "end_col": 60, "end_line": 45, "start_col": 27, "start_line": 45 }
Prims.Tot
val xor_block (b1 b2: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2
val xor_block (b1 b2: block) : Tot block let xor_block (b1 b2: block) : Tot block =
false
null
false
map2 (logxor #U8) b1 b2
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Lib.Sequence.map2", "Spec.AES.elem", "Lib.IntTypes.logxor", "Lib.IntTypes.U8", "Lib.IntTypes.SEC" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val xor_block (b1 b2: block) : Tot block
[]
Spec.AES.xor_block
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b1: Spec.AES.block -> b2: Spec.AES.block -> Spec.AES.block
{ "end_col": 25, "end_line": 152, "start_col": 2, "start_line": 152 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99)
let sub_byte (input: elem) =
false
null
false
let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99)
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.elem", "Spec.AES.op_Hat_Dot", "Spec.AES.op_Less_Less_Less_Dot", "Lib.IntTypes.size", "Spec.AES.to_elem", "Spec.GaloisField.felem", "Spec.AES.gf8", "Spec.GaloisField.finv", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16)
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sub_byte : input: Spec.AES.elem -> Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC
[]
Spec.AES.sub_byte
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
input: Spec.AES.elem -> Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC
{ "end_col": 14, "end_line": 55, "start_col": 27, "start_line": 48 }
Prims.Tot
val inv_subBytes (state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let inv_subBytes (state:block) : Tot block = map inv_sub_byte state
val inv_subBytes (state: block) : Tot block let inv_subBytes (state: block) : Tot block =
false
null
false
map inv_sub_byte state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Lib.Sequence.map", "Spec.AES.elem", "Spec.AES.inv_sub_byte" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val inv_subBytes (state: block) : Tot block
[]
Spec.AES.inv_subBytes
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
state: Spec.AES.block -> Spec.AES.block
{ "end_col": 24, "end_line": 71, "start_col": 2, "start_line": 71 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16)
let aes_xkey (v: variant) =
false
null
false
lseq elem ((num_rounds v + 1) * 16)
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Lib.Sequence.lseq", "Spec.AES.elem", "FStar.Mul.op_Star", "Prims.op_Addition", "Spec.AES.num_rounds" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_xkey : v: Spec.AES.variant -> Type0
[]
Spec.AES.aes_xkey
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> Type0
{ "end_col": 60, "end_line": 44, "start_col": 27, "start_line": 44 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_key (v:variant) = lbytes (key_size v)
let aes_key (v: variant) =
false
null
false
lbytes (key_size v)
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Lib.ByteSequence.lbytes", "Spec.AES.key_size" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_key : v: Spec.AES.variant -> Type0
[]
Spec.AES.aes_key
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> Type0
{ "end_col": 45, "end_line": 43, "start_col": 26, "start_line": 43 }
Prims.Tot
val aes_ctr_key_block1 (v: variant) (k: aes_key v) (n_len: size_nat{n_len <= 16}) (n: lbytes n_len) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_ctr_key_block1 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 1 in aes_ctr_current_key_block v st
val aes_ctr_key_block1 (v: variant) (k: aes_key v) (n_len: size_nat{n_len <= 16}) (n: lbytes n_len) : Tot block let aes_ctr_key_block1 (v: variant) (k: aes_key v) (n_len: size_nat{n_len <= 16}) (n: lbytes n_len) : Tot block =
false
null
false
let st = aes_ctr_init v k n_len n 1 in aes_ctr_current_key_block v st
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Spec.AES.aes_key", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.ByteSequence.lbytes", "Spec.AES.aes_ctr_current_key_block", "Spec.AES.aes_ctr_state", "Spec.AES.aes_ctr_init", "Spec.AES.block" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state let aes_decrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_dec_rounds v k state in let state = aes_dec_last kn state in state let aes_ctr_key_block (v:variant) (k:aes_xkey v) (n:lbytes 12) (c:size_nat) : Tot block = let ctrby = nat_to_bytes_be 4 c in let input = create 16 (u8 0) in let input = repeati #(lbytes 16) 12 (fun i b -> b.[i] <- n.[i]) input in let input = repeati #(lbytes 16) 4 (fun i b -> b.[12+i] <- (Seq.index ctrby i)) input in aes_encrypt_block v k input noeq type aes_ctr_state (v:variant) = { key_ex: lbytes ((num_rounds v + 1) * 16); block: lbytes 16; } let aes_ctr_add_counter (v:variant) (st:aes_ctr_state v) (incr:size_nat) : Tot (aes_ctr_state v) = let n = nat_from_bytes_be st.block in let n' = (n + incr) % pow2 128 in let nblock' = nat_to_bytes_be 16 n' in {st with block = nblock'} let aes_ctr_init (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) (c0:size_nat) : Tot (aes_ctr_state v) = let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[i] <- n.[i]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input} in aes_ctr_add_counter v st0 c0 let aes_ctr_current_key_block (v:variant) (st:aes_ctr_state v) : Tot block = aes_encrypt_block v st.key_ex st.block let aes_ctr_key_block0 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 0 in aes_ctr_current_key_block v st
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_ctr_key_block1 (v: variant) (k: aes_key v) (n_len: size_nat{n_len <= 16}) (n: lbytes n_len) : Tot block
[]
Spec.AES.aes_ctr_key_block1
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> k: Spec.AES.aes_key v -> n_len: Lib.IntTypes.size_nat{n_len <= 16} -> n: Lib.ByteSequence.lbytes n_len -> Spec.AES.block
{ "end_col": 32, "end_line": 363, "start_col": 109, "start_line": 361 }
Prims.Tot
val sub_word (w: word) : Tot word
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sub_word (w:word) : Tot word = map sub_byte w
val sub_word (w: word) : Tot word let sub_word (w: word) : Tot word =
false
null
false
map sub_byte w
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.word", "Lib.Sequence.map", "Spec.AES.elem", "Spec.AES.sub_byte" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]]
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sub_word (w: word) : Tot word
[]
Spec.AES.sub_word
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
w: Spec.AES.word -> Spec.AES.word
{ "end_col": 16, "end_line": 187, "start_col": 2, "start_line": 187 }
Prims.Tot
val aes_dec_rounds (v: variant) (key: aes_ikey v) (state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state
val aes_dec_rounds (v: variant) (key: aes_ikey v) (state: block) : Tot block let aes_dec_rounds (v: variant) (key: aes_ikey v) (state: block) : Tot block =
false
null
false
repeati (num_rounds v - 1) (fun i -> aes_dec (sub key (16 * i) 16)) state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Spec.AES.aes_ikey", "Spec.AES.block", "Lib.LoopCombinators.repeati", "Prims.op_Subtraction", "Spec.AES.num_rounds", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Spec.AES.aes_dec", "Lib.Sequence.sub", "Spec.AES.elem", "FStar.Mul.op_Star" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_dec_rounds (v: variant) (key: aes_ikey v) (state: block) : Tot block
[]
Spec.AES.aes_dec_rounds
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> key: Spec.AES.aes_ikey v -> state: Spec.AES.block -> Spec.AES.block
{ "end_col": 71, "end_line": 317, "start_col": 2, "start_line": 317 }
Prims.Tot
val inv_shiftRows (state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state
val inv_shiftRows (state: block) : Tot block let inv_shiftRows (state: block) : Tot block =
false
null
false
let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Spec.AES.shiftRow" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val inv_shiftRows (state: block) : Tot block
[]
Spec.AES.inv_shiftRows
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
state: Spec.AES.block -> Spec.AES.block
{ "end_col": 7, "end_line": 94, "start_col": 46, "start_line": 90 }
Prims.Tot
val rcon_l:list elem
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ]
val rcon_l:list elem let rcon_l:list elem =
false
null
false
[ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ]
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Prims.Cons", "Spec.AES.elem", "Spec.AES.to_elem", "Prims.Nil" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1)
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rcon_l:list elem
[]
Spec.AES.rcon_l
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.list Spec.AES.elem
{ "end_col": 1, "end_line": 199, "start_col": 25, "start_line": 195 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s
let inv_sub_byte (input: elem) =
false
null
false
let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.elem", "Spec.GaloisField.finv", "Spec.AES.gf8", "Spec.AES.op_Hat_Dot", "Spec.AES.op_Less_Less_Less_Dot", "Lib.IntTypes.size", "Lib.IntTypes.u8", "Spec.GaloisField.felem" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99)
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val inv_sub_byte : input: Spec.AES.elem -> Spec.GaloisField.felem Spec.AES.gf8
[]
Spec.AES.inv_sub_byte
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
input: Spec.AES.elem -> Spec.GaloisField.felem Spec.AES.gf8
{ "end_col": 8, "end_line": 65, "start_col": 31, "start_line": 57 }
Prims.Tot
val mixColumns (state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state
val mixColumns (state: block) : Tot block let mixColumns (state: block) : Tot block =
false
null
false
let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Spec.AES.mixColumn" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mixColumns (state: block) : Tot block
[]
Spec.AES.mixColumns
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
state: Spec.AES.block -> Spec.AES.block
{ "end_col": 7, "end_line": 130, "start_col": 42, "start_line": 125 }
Prims.Tot
val key_expansion_step (p assist: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist
val key_expansion_step (p assist: block) : Tot block let key_expansion_step (p assist: block) : Tot block =
false
null
false
let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Spec.AES.xor_block", "Lib.Sequence.update_sub", "Spec.AES.elem", "Lib.Sequence.sub", "Lib.Sequence.lseq", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.create", "Spec.AES.to_elem", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.index", "Lib.Sequence.create" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val key_expansion_step (p assist: block) : Tot block
[]
Spec.AES.key_expansion_step
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Spec.AES.block -> assist: Spec.AES.block -> Spec.AES.block
{ "end_col": 20, "end_line": 248, "start_col": 61, "start_line": 242 }
Prims.Tot
val aes_ctr_encrypt_block (v: variant) (st0: aes_ctr_state v) (incr: size_nat) (b: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_ctr_encrypt_block (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (b:block) : Tot block = let st = aes_ctr_add_counter v st0 incr in let kb = aes_ctr_current_key_block v st in map2 (^.) b kb
val aes_ctr_encrypt_block (v: variant) (st0: aes_ctr_state v) (incr: size_nat) (b: block) : Tot block let aes_ctr_encrypt_block (v: variant) (st0: aes_ctr_state v) (incr: size_nat) (b: block) : Tot block =
false
null
false
let st = aes_ctr_add_counter v st0 incr in let kb = aes_ctr_current_key_block v st in map2 ( ^. ) b kb
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Spec.AES.aes_ctr_state", "Lib.IntTypes.size_nat", "Spec.AES.block", "Lib.Sequence.map2", "Spec.AES.elem", "Spec.AES.op_Hat_Dot", "Spec.AES.aes_ctr_current_key_block", "Spec.AES.aes_ctr_add_counter" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state let aes_decrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_dec_rounds v k state in let state = aes_dec_last kn state in state let aes_ctr_key_block (v:variant) (k:aes_xkey v) (n:lbytes 12) (c:size_nat) : Tot block = let ctrby = nat_to_bytes_be 4 c in let input = create 16 (u8 0) in let input = repeati #(lbytes 16) 12 (fun i b -> b.[i] <- n.[i]) input in let input = repeati #(lbytes 16) 4 (fun i b -> b.[12+i] <- (Seq.index ctrby i)) input in aes_encrypt_block v k input noeq type aes_ctr_state (v:variant) = { key_ex: lbytes ((num_rounds v + 1) * 16); block: lbytes 16; } let aes_ctr_add_counter (v:variant) (st:aes_ctr_state v) (incr:size_nat) : Tot (aes_ctr_state v) = let n = nat_from_bytes_be st.block in let n' = (n + incr) % pow2 128 in let nblock' = nat_to_bytes_be 16 n' in {st with block = nblock'} let aes_ctr_init (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) (c0:size_nat) : Tot (aes_ctr_state v) = let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[i] <- n.[i]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input} in aes_ctr_add_counter v st0 c0 let aes_ctr_current_key_block (v:variant) (st:aes_ctr_state v) : Tot block = aes_encrypt_block v st.key_ex st.block let aes_ctr_key_block0 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 0 in aes_ctr_current_key_block v st let aes_ctr_key_block1 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 1 in aes_ctr_current_key_block v st let aes_ctr_encrypt_block (v:variant) (st0:aes_ctr_state v) (incr:size_nat)
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_ctr_encrypt_block (v: variant) (st0: aes_ctr_state v) (incr: size_nat) (b: block) : Tot block
[]
Spec.AES.aes_ctr_encrypt_block
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> st0: Spec.AES.aes_ctr_state v -> incr: Lib.IntTypes.size_nat -> b: Spec.AES.block -> Spec.AES.block
{ "end_col": 16, "end_line": 374, "start_col": 13, "start_line": 370 }
Prims.Tot
val aes_ctr_encrypt_stream: v:variant -> st:aes_ctr_state v -> msg:bytes{length msg / 16 <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg})
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_ctr_encrypt_stream v st msg = map_blocks 16 msg (aes_ctr_encrypt_block v st) (aes_ctr_encrypt_last v st)
val aes_ctr_encrypt_stream: v:variant -> st:aes_ctr_state v -> msg:bytes{length msg / 16 <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg}) let aes_ctr_encrypt_stream v st msg =
false
null
false
map_blocks 16 msg (aes_ctr_encrypt_block v st) (aes_ctr_encrypt_last v st)
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Spec.AES.aes_ctr_state", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.max_size_t", "Lib.Sequence.map_blocks", "Spec.AES.aes_ctr_encrypt_block", "Spec.AES.aes_ctr_encrypt_last", "Prims.eq2", "Prims.nat" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state let aes_decrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_dec_rounds v k state in let state = aes_dec_last kn state in state let aes_ctr_key_block (v:variant) (k:aes_xkey v) (n:lbytes 12) (c:size_nat) : Tot block = let ctrby = nat_to_bytes_be 4 c in let input = create 16 (u8 0) in let input = repeati #(lbytes 16) 12 (fun i b -> b.[i] <- n.[i]) input in let input = repeati #(lbytes 16) 4 (fun i b -> b.[12+i] <- (Seq.index ctrby i)) input in aes_encrypt_block v k input noeq type aes_ctr_state (v:variant) = { key_ex: lbytes ((num_rounds v + 1) * 16); block: lbytes 16; } let aes_ctr_add_counter (v:variant) (st:aes_ctr_state v) (incr:size_nat) : Tot (aes_ctr_state v) = let n = nat_from_bytes_be st.block in let n' = (n + incr) % pow2 128 in let nblock' = nat_to_bytes_be 16 n' in {st with block = nblock'} let aes_ctr_init (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) (c0:size_nat) : Tot (aes_ctr_state v) = let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[i] <- n.[i]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input} in aes_ctr_add_counter v st0 c0 let aes_ctr_current_key_block (v:variant) (st:aes_ctr_state v) : Tot block = aes_encrypt_block v st.key_ex st.block let aes_ctr_key_block0 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 0 in aes_ctr_current_key_block v st let aes_ctr_key_block1 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 1 in aes_ctr_current_key_block v st let aes_ctr_encrypt_block (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (b:block) : Tot block = let st = aes_ctr_add_counter v st0 incr in let kb = aes_ctr_current_key_block v st in map2 (^.) b kb let aes_ctr_encrypt_last (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (len:size_nat{len < 16}) (b:lbytes len): Tot (lbytes len) = let plain = create 16 (u8 0) in let plain = update_sub plain 0 (length b) b in let cipher = aes_ctr_encrypt_block v st0 incr plain in sub cipher 0 (length b) val aes_ctr_encrypt_stream: v:variant -> st:aes_ctr_state v -> msg:bytes{length msg / 16 <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg})
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_ctr_encrypt_stream: v:variant -> st:aes_ctr_state v -> msg:bytes{length msg / 16 <= max_size_t} -> Tot (ciphertext:bytes{length ciphertext == length msg})
[]
Spec.AES.aes_ctr_encrypt_stream
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> st: Spec.AES.aes_ctr_state v -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length msg / 16 <= Lib.IntTypes.max_size_t} -> ciphertext: Lib.ByteSequence.bytes{Lib.Sequence.length ciphertext == Lib.Sequence.length msg}
{ "end_col": 31, "end_line": 398, "start_col": 2, "start_line": 396 }
Prims.Tot
val aes_ctr_init (v: variant) (k: aes_key v) (n_len: size_nat{n_len <= 16}) (n: lbytes n_len) (c0: size_nat) : Tot (aes_ctr_state v)
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_ctr_init (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) (c0:size_nat) : Tot (aes_ctr_state v) = let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[i] <- n.[i]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input} in aes_ctr_add_counter v st0 c0
val aes_ctr_init (v: variant) (k: aes_key v) (n_len: size_nat{n_len <= 16}) (n: lbytes n_len) (c0: size_nat) : Tot (aes_ctr_state v) let aes_ctr_init (v: variant) (k: aes_key v) (n_len: size_nat{n_len <= 16}) (n: lbytes n_len) (c0: size_nat) : Tot (aes_ctr_state v) =
false
null
false
let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[ i ] <- n.[ i ]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input } in aes_ctr_add_counter v st0 c0
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Spec.AES.aes_key", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.ByteSequence.lbytes", "Spec.AES.aes_ctr_add_counter", "Spec.AES.aes_ctr_state", "Spec.AES.Mkaes_ctr_state", "Spec.AES.aes_xkey", "Spec.AES.aes_key_expansion", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.LoopCombinators.repeati", "Prims.nat", "Prims.op_LessThan", "Lib.Sequence.op_String_Assignment", "Lib.IntTypes.uint_t", "Lib.Sequence.op_String_Access", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Prims.l_Forall", "Prims.l_imp", "Lib.Sequence.index", "Lib.Sequence.create", "Lib.IntTypes.u8" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state let aes_decrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_dec_rounds v k state in let state = aes_dec_last kn state in state let aes_ctr_key_block (v:variant) (k:aes_xkey v) (n:lbytes 12) (c:size_nat) : Tot block = let ctrby = nat_to_bytes_be 4 c in let input = create 16 (u8 0) in let input = repeati #(lbytes 16) 12 (fun i b -> b.[i] <- n.[i]) input in let input = repeati #(lbytes 16) 4 (fun i b -> b.[12+i] <- (Seq.index ctrby i)) input in aes_encrypt_block v k input noeq type aes_ctr_state (v:variant) = { key_ex: lbytes ((num_rounds v + 1) * 16); block: lbytes 16; } let aes_ctr_add_counter (v:variant) (st:aes_ctr_state v) (incr:size_nat) : Tot (aes_ctr_state v) = let n = nat_from_bytes_be st.block in let n' = (n + incr) % pow2 128 in let nblock' = nat_to_bytes_be 16 n' in {st with block = nblock'}
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_ctr_init (v: variant) (k: aes_key v) (n_len: size_nat{n_len <= 16}) (n: lbytes n_len) (c0: size_nat) : Tot (aes_ctr_state v)
[]
Spec.AES.aes_ctr_init
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> k: Spec.AES.aes_key v -> n_len: Lib.IntTypes.size_nat{n_len <= 16} -> n: Lib.ByteSequence.lbytes n_len -> c0: Lib.IntTypes.size_nat -> Spec.AES.aes_ctr_state v
{ "end_col": 30, "end_line": 352, "start_col": 129, "start_line": 347 }
Prims.Tot
val inv_mixColumns (state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state
val inv_mixColumns (state: block) : Tot block let inv_mixColumns (state: block) : Tot block =
false
null
false
let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.block", "Spec.AES.inv_mixColumn" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val inv_mixColumns (state: block) : Tot block
[]
Spec.AES.inv_mixColumns
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
state: Spec.AES.block -> Spec.AES.block
{ "end_col": 7, "end_line": 149, "start_col": 46, "start_line": 144 }
Prims.Tot
val keygen_assist0 (rcon: elem) (s: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st
val keygen_assist0 (rcon: elem) (s: block) : Tot block let keygen_assist0 (rcon: elem) (s: block) : Tot block =
false
null
false
let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.elem", "Spec.AES.block", "Lib.Sequence.lseq", "Prims.l_and", "Prims.eq2", "Lib.Sequence.sub", "Prims.l_Forall", "Prims.nat", "Prims.l_or", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index", "Lib.Sequence.update_sub", "Spec.AES.aes_keygen_assist" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st
false
true
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val keygen_assist0 (rcon: elem) (s: block) : Tot block
[]
Spec.AES.keygen_assist0
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
rcon: Spec.AES.elem -> s: Spec.AES.block -> Spec.AES.block
{ "end_col": 4, "end_line": 234, "start_col": 54, "start_line": 230 }
Prims.Tot
val mixColumn (c: size_nat{c < 4}) (state: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state
val mixColumn (c: size_nat{c < 4}) (state: block) : Tot block let mixColumn (c: size_nat{c < 4}) (state: block) : Tot block =
false
null
false
let i0 = 4 * c in let s0 = state.[ i0 ] in let s1 = state.[ i0 + 1 ] in let s2 = state.[ i0 + 2 ] in let s3 = state.[ i0 + 3 ] in let state = state.[ i0 ] <- mix4 s0 s1 s2 s3 in let state = state.[ i0 + 1 ] <- mix4 s1 s2 s3 s0 in let state = state.[ i0 + 2 ] <- mix4 s2 s3 s0 s1 in let state = state.[ i0 + 3 ] <- mix4 s3 s0 s1 s2 in state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThan", "Spec.AES.block", "Lib.Sequence.lseq", "Spec.AES.elem", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Prims.op_Addition", "Spec.AES.mix4", "Lib.Sequence.index", "Prims.l_Forall", "Prims.nat", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.op_String_Assignment", "Lib.Sequence.op_String_Access", "Prims.int", "FStar.Mul.op_Star" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9)
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mixColumn (c: size_nat{c < 4}) (state: block) : Tot block
[]
Spec.AES.mixColumn
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Lib.IntTypes.size_nat{c < 4} -> state: Spec.AES.block -> Spec.AES.block
{ "end_col": 7, "end_line": 123, "start_col": 61, "start_line": 113 }
Prims.Tot
val aes_encrypt_block (v: variant) (key: aes_xkey v) (input: block) : Tot block
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state
val aes_encrypt_block (v: variant) (key: aes_xkey v) (input: block) : Tot block let aes_encrypt_block (v: variant) (key: aes_xkey v) (input: block) : Tot block =
false
null
false
let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v - 1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Spec.AES.aes_xkey", "Spec.AES.block", "Spec.AES.aes_enc_last", "Spec.AES.aes_enc_rounds", "Spec.AES.addRoundKey", "Lib.Sequence.lseq", "Spec.AES.elem", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.op_Multiply", "Prims.op_Addition", "Spec.AES.num_rounds", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.sub", "FStar.Mul.op_Star", "Prims.op_Subtraction", "Lib.Sequence.slice" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_encrypt_block (v: variant) (key: aes_xkey v) (input: block) : Tot block
[]
Spec.AES.aes_encrypt_block
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> key: Spec.AES.aes_xkey v -> input: Spec.AES.block -> Spec.AES.block
{ "end_col": 7, "end_line": 314, "start_col": 78, "start_line": 306 }
Prims.Tot
val aes_ctr_encrypt_last (v: variant) (st0: aes_ctr_state v) (incr: size_nat) (len: size_nat{len < 16}) (b: lbytes len) : Tot (lbytes len)
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_ctr_encrypt_last (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (len:size_nat{len < 16}) (b:lbytes len): Tot (lbytes len) = let plain = create 16 (u8 0) in let plain = update_sub plain 0 (length b) b in let cipher = aes_ctr_encrypt_block v st0 incr plain in sub cipher 0 (length b)
val aes_ctr_encrypt_last (v: variant) (st0: aes_ctr_state v) (incr: size_nat) (len: size_nat{len < 16}) (b: lbytes len) : Tot (lbytes len) let aes_ctr_encrypt_last (v: variant) (st0: aes_ctr_state v) (incr: size_nat) (len: size_nat{len < 16}) (b: lbytes len) : Tot (lbytes len) =
false
null
false
let plain = create 16 (u8 0) in let plain = update_sub plain 0 (length b) b in let cipher = aes_ctr_encrypt_block v st0 incr plain in sub cipher 0 (length b)
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Spec.AES.aes_ctr_state", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThan", "Lib.ByteSequence.lbytes", "Lib.Sequence.sub", "Spec.AES.elem", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.AES.block", "Spec.AES.aes_ctr_encrypt_block", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Prims.l_and", "Prims.eq2", "Prims.l_Forall", "Prims.nat", "Prims.l_or", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index", "Lib.Sequence.update_sub", "FStar.Seq.Base.seq", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Prims.l_imp", "Lib.Sequence.create", "Lib.IntTypes.u8" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex let aes_enc_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_enc (sub key (16*i) 16)) state let aes_encrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_enc_rounds v k state in let state = aes_enc_last kn state in state let aes_dec_rounds (v:variant) (key:aes_ikey v) (state:block) : Tot block = repeati (num_rounds v-1) (fun i -> aes_dec (sub key (16*i) 16)) state let aes_decrypt_block (v:variant) (key:aes_xkey v) (input:block) : Tot block = let state = input in let k0 = slice key 0 16 in let k = sub key 16 ((num_rounds v-1) * 16) in let kn = sub key (num_rounds v * 16) 16 in let state = addRoundKey k0 state in let state = aes_dec_rounds v k state in let state = aes_dec_last kn state in state let aes_ctr_key_block (v:variant) (k:aes_xkey v) (n:lbytes 12) (c:size_nat) : Tot block = let ctrby = nat_to_bytes_be 4 c in let input = create 16 (u8 0) in let input = repeati #(lbytes 16) 12 (fun i b -> b.[i] <- n.[i]) input in let input = repeati #(lbytes 16) 4 (fun i b -> b.[12+i] <- (Seq.index ctrby i)) input in aes_encrypt_block v k input noeq type aes_ctr_state (v:variant) = { key_ex: lbytes ((num_rounds v + 1) * 16); block: lbytes 16; } let aes_ctr_add_counter (v:variant) (st:aes_ctr_state v) (incr:size_nat) : Tot (aes_ctr_state v) = let n = nat_from_bytes_be st.block in let n' = (n + incr) % pow2 128 in let nblock' = nat_to_bytes_be 16 n' in {st with block = nblock'} let aes_ctr_init (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) (c0:size_nat) : Tot (aes_ctr_state v) = let input = create 16 (u8 0) in let input = repeati #(lbytes 16) n_len (fun i b -> b.[i] <- n.[i]) input in let key_ex = aes_key_expansion v k in let st0 = { key_ex = key_ex; block = input} in aes_ctr_add_counter v st0 c0 let aes_ctr_current_key_block (v:variant) (st:aes_ctr_state v) : Tot block = aes_encrypt_block v st.key_ex st.block let aes_ctr_key_block0 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 0 in aes_ctr_current_key_block v st let aes_ctr_key_block1 (v:variant) (k:aes_key v) (n_len:size_nat{n_len <= 16}) (n:lbytes n_len) : Tot block = let st = aes_ctr_init v k n_len n 1 in aes_ctr_current_key_block v st let aes_ctr_encrypt_block (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (b:block) : Tot block = let st = aes_ctr_add_counter v st0 incr in let kb = aes_ctr_current_key_block v st in map2 (^.) b kb let aes_ctr_encrypt_last (v:variant) (st0:aes_ctr_state v) (incr:size_nat) (len:size_nat{len < 16})
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_ctr_encrypt_last (v: variant) (st0: aes_ctr_state v) (incr: size_nat) (len: size_nat{len < 16}) (b: lbytes len) : Tot (lbytes len)
[]
Spec.AES.aes_ctr_encrypt_last
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> st0: Spec.AES.aes_ctr_state v -> incr: Lib.IntTypes.size_nat -> len: Lib.IntTypes.size_nat{len < 16} -> b: Lib.ByteSequence.lbytes len -> Lib.ByteSequence.lbytes len
{ "end_col": 25, "end_line": 387, "start_col": 20, "start_line": 382 }
Prims.Tot
val aes_dec_key_expansion (v: variant) (key: aes_key v) : aes_xkey v
[ { "abbrev": false, "full_module": "Spec.GaloisField", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_dec_key_expansion (v:variant) (key:aes_key v): aes_xkey v = let ekey_ex : aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _,key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (),inv_mixColumns b else (),b) () in key_ex
val aes_dec_key_expansion (v: variant) (key: aes_key v) : aes_xkey v let aes_dec_key_expansion (v: variant) (key: aes_key v) : aes_xkey v =
false
null
false
let ekey_ex:aes_xkey v = aes_key_expansion v key in let k0 = sub ekey_ex 0 16 in let kn = sub ekey_ex ((num_rounds v) * 16) 16 in let _, key_ex = generate_blocks 16 (num_rounds v + 1) (num_rounds v + 1) (fun i -> unit) (fun i a -> let b = sub ekey_ex ((num_rounds v - i) * 16) 16 in if i = 0 then (), b else if i < num_rounds v then (), inv_mixColumns b else (), b) () in key_ex
{ "checked_file": "Spec.AES.fst.checked", "dependencies": [ "Spec.GaloisField.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.AES.fst" }
[ "total" ]
[ "Spec.AES.variant", "Spec.AES.aes_key", "Prims.unit", "Lib.Sequence.seq", "Spec.AES.elem", "Prims.eq2", "Prims.int", "Lib.Sequence.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Spec.AES.num_rounds", "Spec.AES.aes_xkey", "FStar.Pervasives.Native.tuple2", "Prims.op_Multiply", "Lib.Sequence.generate_blocks", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Equality", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "Spec.AES.inv_mixColumns", "Lib.Sequence.lseq", "Prims.l_and", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.op_Subtraction", "Prims.l_Forall", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.sub", "Spec.AES.aes_key_expansion" ]
[]
module Spec.AES open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators open Spec.GaloisField /// Constants and Types (* GF(8) Field *) let irred = u8 0x1b let gf8 = gf U8 irred let elem = felem gf8 let to_elem = to_felem #gf8 let zero = to_elem 0 let two = to_elem 2 let three = to_elem 3 (* These operations are normalized here to avoid a huge blowup in generate code size *) let ( <<<. ) x y = normalize_term (rotate_left #U8 #SEC x y) let ( ^. ) x y = normalize_term (logxor #U8 #SEC x y) (* Specification of the Rijndael S-Box : *) type word = lseq elem 4 type block = lseq elem 16 type variant = | AES128 | AES256 let num_rounds (v:variant) = match v with | AES128 -> 10 | AES256 -> 14 let key_size (v:variant) = match v with | AES128 -> 16 | AES256 -> 32 let aes_key (v:variant) = lbytes (key_size v) let aes_xkey (v:variant) = lseq elem ((num_rounds v+1) * 16) let aes_ikey (v:variant) = lseq elem ((num_rounds v-1) * 16) let sub_byte (input:elem) = let s = finv input in s ^. (s <<<. size 1) ^. (s <<<. size 2) ^. (s <<<. size 3) ^. (s <<<. size 4) ^. (to_elem 99) let inv_sub_byte (input:elem) = let s = input in let s:elem = (s <<<. size 1) ^. (s <<<. size 3) ^. (s <<<. size 6) ^. (u8 5) in finv s let subBytes (state:block) : Tot block = map sub_byte state let inv_subBytes (state:block) : Tot block = map inv_sub_byte state let shiftRow (i:size_nat{i < 4}) (shift:size_nat{i < 4}) (state:block) : Tot block = let tmp0 = state.[i + (4 * (shift % 4))] in let tmp1 = state.[i + (4 * ((shift + 1) % 4))] in let tmp2 = state.[i + (4 * ((shift + 2) % 4))] in let tmp3 = state.[i + (4 * ((shift + 3) % 4))] in let state = state.[i] <- tmp0 in let state = state.[i+4] <- tmp1 in let state = state.[i+8] <- tmp2 in let state = state.[i+12] <- tmp3 in state let shiftRows (state: block) : Tot block = let state = shiftRow 1 1 state in let state = shiftRow 2 2 state in let state = shiftRow 3 3 state in state let inv_shiftRows (state: block) : Tot block = let state = shiftRow 1 3 state in let state = shiftRow 2 2 state in let state = shiftRow 3 1 state in state let mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (s0 `fmul` two) `fadd` (s1 `fmul` three) `fadd` s2 `fadd` s3 let inv_mix4 (s0:elem) (s1:elem) (s2:elem) (s3:elem) : Tot elem = (* (s0 `fmul` to_elem 11) `fadd` (s1 `fmul` to_elem 13) `fadd` (s2 `fmul` to_elem 9) `fadd` (s3 `fmul` to_elem 14) *) (s0 `fmul` to_elem 14) `fadd` (s1 `fmul` to_elem 11) `fadd` (s2 `fmul` to_elem 13) `fadd` (s3 `fmul` to_elem 9) let mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- mix4 s3 s0 s1 s2 in state let mixColumns (state:block) : Tot block = let state = mixColumn 0 state in let state = mixColumn 1 state in let state = mixColumn 2 state in let state = mixColumn 3 state in state let inv_mixColumn (c:size_nat{c < 4}) (state:block) : Tot block = let i0 = 4 * c in let s0 = state.[i0] in let s1 = state.[i0 + 1] in let s2 = state.[i0 + 2] in let s3 = state.[i0 + 3] in let state = state.[i0] <- inv_mix4 s0 s1 s2 s3 in let state = state.[i0+1] <- inv_mix4 s1 s2 s3 s0 in let state = state.[i0+2] <- inv_mix4 s2 s3 s0 s1 in let state = state.[i0+3] <- inv_mix4 s3 s0 s1 s2 in state let inv_mixColumns (state:block) : Tot block = let state = inv_mixColumn 0 state in let state = inv_mixColumn 1 state in let state = inv_mixColumn 2 state in let state = inv_mixColumn 3 state in state let xor_block (b1:block) (b2:block) : Tot block = map2 (logxor #U8) b1 b2 let addRoundKey (key:block) (state:block) : Tot block = xor_block state key let aes_enc (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = mixColumns state in let state = addRoundKey key state in state let aes_enc_last (key:block) (state:block) : Tot block = let state = subBytes state in let state = shiftRows state in let state = addRoundKey key state in state let aes_dec (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = inv_mixColumns state in let state = addRoundKey key state in state let aes_dec_last (key:block) (state:block) : Tot block = let state = inv_subBytes state in let state = inv_shiftRows state in let state = addRoundKey key state in state let rotate_word (w:word) : Tot word = of_list [w.[1]; w.[2]; w.[3]; w.[0]] let sub_word (w:word) : Tot word = map sub_byte w val rcon_spec: i:size_nat -> Tot elem let rec rcon_spec i = if i = 0 then to_elem 0x8d else if i = 1 then to_elem 1 else two `fmul` rcon_spec (i - 1) let rcon_l : list elem = [ to_elem 0x8d; to_elem 0x01; to_elem 0x02; to_elem 0x04; to_elem 0x08; to_elem 0x10; to_elem 0x20; to_elem 0x40; to_elem 0x80; to_elem 0x1b; to_elem 0x36 ] let rcon_seq : lseq elem 11 = assert_norm (List.Tot.length rcon_l == 11); of_list rcon_l #reset-options "--z3rlimit 100" let aes_keygen_assist (rcon:elem) (s:block) : Tot block = let st = create 16 (to_elem 0) in let st = st.[0] <- sub_byte s.[4] in let st = st.[1] <- sub_byte s.[5] in let st = st.[2] <- sub_byte s.[6] in let st = st.[3] <- sub_byte s.[7] in let st = st.[4] <- rcon ^. sub_byte s.[5] in let st = st.[6] <- sub_byte s.[6] in let st = st.[6] <- sub_byte s.[7] in let st = st.[7] <- sub_byte s.[4] in let st = st.[8] <- sub_byte s.[12] in let st = st.[9] <- sub_byte s.[13] in let st = st.[10] <- sub_byte s.[14] in let st = st.[11] <- sub_byte s.[15] in let st = st.[12] <- rcon ^. sub_byte s.[13] in let st = st.[13] <- sub_byte s.[14] in let st = st.[14] <- sub_byte s.[15] in let st = st.[15] <- sub_byte s.[12] in st let keygen_assist0 (rcon:elem) (s:block) : Tot block = let st = aes_keygen_assist rcon s in let st = update_sub st 8 4 (sub st 12 4) in let st = update_sub st 0 8 (sub st 8 8) in st let keygen_assist1 (s:block) : Tot block = let st = aes_keygen_assist zero s in let st = update_sub st 12 4 (sub st 8 4) in let st = update_sub st 0 8 (sub st 8 8) in st let key_expansion_step (p:block) (assist:block) : Tot block = let p0 = create 16 (to_elem 0) in let k = p in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in let k = xor_block k (update_sub p0 4 12 (sub k 0 12)) in xor_block k assist let aes128_key_expansion (key:lbytes 16) : Tot (lseq elem (11 * 16)) = let key_ex = create (11 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 16 key in let key_ex = repeati #(lseq elem (11 * 16)) 10 (fun i kex -> let p = sub kex (i * 16) 16 in let a = keygen_assist0 (rcon_spec (i+1)) p in let n = key_expansion_step p a in update_sub kex ((i+1) * 16) 16 n) key_ex in key_ex let aes256_key_expansion (key:lbytes 32) : Tot (lseq elem (15 * 16)) = let key_ex = create (15 * 16) (to_elem 0) in let key_ex = update_sub key_ex 0 32 key in let key_ex = repeati #(lseq elem (15 * 16)) 6 (fun i key_ex -> let p0 = sub key_ex (2 * i * 16) 16 in let p1 = sub key_ex (((2*i)+1) * 16) 16 in let a0 = keygen_assist0 (rcon_spec (i+1)) p1 in let n0 = key_expansion_step p0 a0 in let a1 = keygen_assist1 n0 in let n1 = key_expansion_step p1 a1 in let key_ex = update_sub key_ex (((2*i)+2) * 16) 16 n0 in update_sub key_ex (((2*i)+3) * 16) 16 n1) key_ex in let p0 = sub key_ex (12 * 16) 16 in let p1 = sub key_ex (13 * 16) 16 in let a14 = keygen_assist0 (rcon_spec 7) p1 in let n14 = key_expansion_step p0 a14 in update_sub key_ex (14 * 16) 16 n14 let aes_key_expansion (v:variant) (key: aes_key v) : aes_xkey v = match v with | AES128 -> aes128_key_expansion key | AES256 -> aes256_key_expansion key
false
false
Spec.AES.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_dec_key_expansion (v: variant) (key: aes_key v) : aes_xkey v
[]
Spec.AES.aes_dec_key_expansion
{ "file_name": "specs/Spec.AES.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Spec.AES.variant -> key: Spec.AES.aes_key v -> Spec.AES.aes_xkey v
{ "end_col": 8, "end_line": 301, "start_col": 67, "start_line": 289 }