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 mt_get_path_ok_: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> t:merkle_tree #hsz n -> i:nat{i < pow2 n} -> Lemma (mt_verify_ #_ #f (mt_get_path #_ #f t i) i (mt_get t i) == mt_get_root #_ #f t)
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 mt_get_path_ok_ #hsz #f #n mt idx = if n = 0 then () else begin assert (S.head (mt_get_path #_ #f mt idx) == (if idx % 2 = 0 then mt.[idx + 1] else mt.[idx - 1])); assert (S.equal (S.tail (mt_get_path #_ #f mt idx)) (mt_get_path #_ #f (mt_next_lv #_ #f mt) (idx / 2))); mt_get_path_ok_ #_ #f (mt_next_lv #_ #f mt) (idx / 2); mt_next_lv_get #_ #f mt idx end
val mt_get_path_ok_: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> t:merkle_tree #hsz n -> i:nat{i < pow2 n} -> Lemma (mt_verify_ #_ #f (mt_get_path #_ #f t i) i (mt_get t i) == mt_get_root #_ #f t) let rec mt_get_path_ok_ #hsz #f #n mt idx =
false
null
true
if n = 0 then () else (assert (S.head (mt_get_path #_ #f mt idx) == (if idx % 2 = 0 then mt.[ idx + 1 ] else mt.[ idx - 1 ])); assert (S.equal (S.tail (mt_get_path #_ #f mt idx)) (mt_get_path #_ #f (mt_next_lv #_ #f mt) (idx / 2))); mt_get_path_ok_ #_ #f (mt_next_lv #_ #f mt) (idx / 2); mt_next_lv_get #_ #f mt idx)
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "lemma" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "MerkleTree.Spec.merkle_tree", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.op_Equality", "Prims.int", "Prims.bool", "MerkleTree.Spec.mt_next_lv_get", "Prims.unit", "MerkleTree.Spec.mt_get_path_ok_", "Prims.op_Subtraction", "MerkleTree.Spec.mt_next_lv", "Prims.op_Division", "Prims._assert", "FStar.Seq.Base.equal", "MerkleTree.Spec.padded_hash", "FStar.Seq.Properties.tail", "MerkleTree.Spec.mt_get_path", "Prims.eq2", "FStar.Seq.Properties.head", "Prims.op_Modulus", "MerkleTree.Spec.op_String_Access", "Prims.op_Addition" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end val mt_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> GTot (merkle_tree #hsz (n-1)) let mt_next_lv #_ #f #n mt = hs_next_lv #_ #f #(pow2 (n-1)) mt val mt_next_lv_mt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_left mt)) (mt_left (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_left #hsz #f #n mt = hs_next_lv_slice #_ #f #(pow2 (n-1)) mt 0 (pow2 (n-2)) val mt_next_lv_mt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_right mt)) (mt_right (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_right #hsz #f #n mt = hs_next_lv_slice #hsz #f #(pow2 (n-1)) mt (pow2 (n-2)) (pow2 (n-1)) val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2))) let hs_next_lv_equiv #hsz #f j n hs1 hs2 = forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i:nat{i < j / 2}). hs1'.[i] == padded_hash_fun #hsz f hs1.[2 * i] hs1.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs2'.[i] == padded_hash_fun #hsz f hs2.[2 * i] hs2.[2 * i + 1]); assert (forall (i:nat{i < j}). (S.slice hs1 0 j).[i] == (S.slice hs2 0 j).[i]); assert (forall (i:nat{i < j}). hs1.[i] == hs2.[i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i] == hs2.[2 * i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i + 1] == hs2.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs1'.[i] == hs2'.[i]) val mt_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= pow2 n} -> mt1:merkle_tree #hsz n -> mt2:merkle_tree #hsz n -> Lemma (requires S.equal (S.slice mt1 0 j) (S.slice mt2 0 j)) (ensures S.equal (S.slice (mt_next_lv #_ #f #_ mt1) 0 (j / 2)) (S.slice (mt_next_lv #_ #f #_ mt2) 0 (j / 2))) let mt_next_lv_equiv #hsz #f j n mt1 mt2 = hs_next_lv_equiv #_ #f j (pow2 (n-1)) mt1 mt2 val hs_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> nhs:hashes #hsz {S.length nhs = n} -> GTot Type0 let hs_next_rel #hsz #f n hs nhs = forall (i:nat{i < n}). S.index nhs i == padded_hash_fun #hsz f (S.index hs (2 * i)) (S.index hs (2 * i + 1)) val mt_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> GTot Type0 let mt_next_rel #hsz #f n mt nmt = hs_next_rel #hsz #f (pow2 (n-1)) mt nmt val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs)) let rec hs_next_rel_next_lv #hsz #f n hs nhs = if n = 0 then () else hs_next_rel_next_lv #_ #f (n - 1) (S.slice hs 2 (S.length hs)) (S.slice nhs 1 (S.length nhs)) val mt_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures S.equal nmt (mt_next_lv #_ #f mt)) let mt_next_rel_next_lv #hsz #f n mt nmt = hs_next_rel_next_lv #_ #f (pow2 (n-1)) mt nmt val mt_next_rel_upd_even: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i (padded_hash_fun #hsz f v (S.index mt (2 * i + 1))))) let mt_next_rel_upd_even #hsz #f n mt nmt i v = () #push-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val mt_next_rel_upd_even_pad: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash #hsz -> Lemma (requires (mt_next_rel #_ #f n mt nmt) /\ (S.index mt (2 * i + 1) == HPad)) (ensures (mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i v))) let mt_next_rel_upd_even_pad #hsz #f n mt nmt i v = () #pop-options val mt_next_rel_upd_odd: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i + 1) v) (S.upd nmt i (padded_hash_fun #_ f (S.index mt (2 * i)) v))) let mt_next_rel_upd_odd #hsz #f n mt nmt i v = () // fournet: just [root]? val mt_get_root: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> GTot (padded_hash #hsz) let rec mt_get_root #hsz #f #n mt = if n = 0 then mt.[0] else mt_get_root #_ #f (mt_next_lv #_ #f mt) #push-options "--initial_fuel 2 --max_fuel 2" val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt))) let rec mt_get_root_step #hsz #f #n mt = if n = 1 then () else begin mt_get_root_step #_ #f (mt_next_lv #_ #f mt); mt_next_lv_mt_left #_ #f mt; mt_next_lv_mt_right #_ #f mt end #pop-options type path #hsz n = S.lseq (padded_hash #hsz) n /// We first specify full paths, including padding. val mt_get_path: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> i:nat{i < pow2 n} -> GTot (path #hsz n) let rec mt_get_path #hsz #f #n t i = if n = 0 then S.empty else S.cons (if i % 2 = 0 then t.[i + 1] else t.[i - 1]) (mt_get_path #_ #f (mt_next_lv #_ #f t) (i / 2)) val mt_verify_: #hsz:pos -> #f:hash_fun_t #hsz ->#n:nat -> p:path #hsz n -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> GTot (padded_hash #hsz) let rec mt_verify_ #hsz #f #n p idx h = if n = 0 then h else mt_verify_ #_ #f #(n-1) (S.tail p) (idx / 2) (if idx % 2 = 0 then padded_hash_fun #_ f h (S.head p) else padded_hash_fun #_ f (S.head p) h) val mt_verify: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> p:(path #hsz n) -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> padded_hash #hsz -> GTot prop let mt_verify #hsz #f #n p idx h rt = rt == mt_verify_ #_ #f p idx h /// Correctness: the root of a tree is correctly recomputed from any of its paths val hs_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> hs:hashes{S.length hs = 2 * n} -> idx:nat{idx < 2 * n} -> Lemma ((hs_next_lv #_ #f #n hs).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f hs.[idx] hs.[idx + 1] else padded_hash_fun #_ f hs.[idx - 1] hs.[idx])) let rec hs_next_lv_get #hsz #f #n hs idx = if idx < 2 then () else hs_next_lv_get #_ #f #(n-1) (S.slice hs 2 (S.length hs)) (idx - 2) val mt_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> Lemma ( (mt_next_lv #_ #f mt).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f mt.[idx] mt.[idx + 1] else padded_hash_fun #_ f mt.[idx - 1] mt.[idx])) let mt_next_lv_get #hsz #f #n mt idx = hs_next_lv_get #_ #f #(pow2 (n-1)) mt idx val mt_get_path_ok_: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> t:merkle_tree #hsz n -> i:nat{i < pow2 n} -> Lemma (mt_verify_ #_ #f (mt_get_path #_ #f t i) i (mt_get t i) == mt_get_root #_ #f t)
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mt_get_path_ok_: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> t:merkle_tree #hsz n -> i:nat{i < pow2 n} -> Lemma (mt_verify_ #_ #f (mt_get_path #_ #f t i) i (mt_get t i) == mt_get_root #_ #f t)
[ "recursion" ]
MerkleTree.Spec.mt_get_path_ok_
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
t: MerkleTree.Spec.merkle_tree n -> i: Prims.nat{i < Prims.pow2 n} -> FStar.Pervasives.Lemma (ensures MerkleTree.Spec.mt_verify_ (MerkleTree.Spec.mt_get_path t i) i (MerkleTree.Spec.mt_get t i) == MerkleTree.Spec.mt_get_root t)
{ "end_col": 5, "end_line": 314, "start_col": 2, "start_line": 306 }
FStar.Pervasives.Lemma
val mt_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> Lemma ( (mt_next_lv #_ #f mt).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f mt.[idx] mt.[idx + 1] else padded_hash_fun #_ f mt.[idx - 1] mt.[idx]))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 mt_next_lv_get #hsz #f #n mt idx = hs_next_lv_get #_ #f #(pow2 (n-1)) mt idx
val mt_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> Lemma ( (mt_next_lv #_ #f mt).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f mt.[idx] mt.[idx + 1] else padded_hash_fun #_ f mt.[idx - 1] mt.[idx])) let mt_next_lv_get #hsz #f #n mt idx =
false
null
true
hs_next_lv_get #_ #f #(pow2 (n - 1)) mt idx
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "lemma" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "MerkleTree.Spec.merkle_tree", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "MerkleTree.Spec.hs_next_lv_get", "Prims.op_Subtraction", "Prims.unit" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end val mt_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> GTot (merkle_tree #hsz (n-1)) let mt_next_lv #_ #f #n mt = hs_next_lv #_ #f #(pow2 (n-1)) mt val mt_next_lv_mt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_left mt)) (mt_left (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_left #hsz #f #n mt = hs_next_lv_slice #_ #f #(pow2 (n-1)) mt 0 (pow2 (n-2)) val mt_next_lv_mt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_right mt)) (mt_right (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_right #hsz #f #n mt = hs_next_lv_slice #hsz #f #(pow2 (n-1)) mt (pow2 (n-2)) (pow2 (n-1)) val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2))) let hs_next_lv_equiv #hsz #f j n hs1 hs2 = forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i:nat{i < j / 2}). hs1'.[i] == padded_hash_fun #hsz f hs1.[2 * i] hs1.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs2'.[i] == padded_hash_fun #hsz f hs2.[2 * i] hs2.[2 * i + 1]); assert (forall (i:nat{i < j}). (S.slice hs1 0 j).[i] == (S.slice hs2 0 j).[i]); assert (forall (i:nat{i < j}). hs1.[i] == hs2.[i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i] == hs2.[2 * i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i + 1] == hs2.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs1'.[i] == hs2'.[i]) val mt_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= pow2 n} -> mt1:merkle_tree #hsz n -> mt2:merkle_tree #hsz n -> Lemma (requires S.equal (S.slice mt1 0 j) (S.slice mt2 0 j)) (ensures S.equal (S.slice (mt_next_lv #_ #f #_ mt1) 0 (j / 2)) (S.slice (mt_next_lv #_ #f #_ mt2) 0 (j / 2))) let mt_next_lv_equiv #hsz #f j n mt1 mt2 = hs_next_lv_equiv #_ #f j (pow2 (n-1)) mt1 mt2 val hs_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> nhs:hashes #hsz {S.length nhs = n} -> GTot Type0 let hs_next_rel #hsz #f n hs nhs = forall (i:nat{i < n}). S.index nhs i == padded_hash_fun #hsz f (S.index hs (2 * i)) (S.index hs (2 * i + 1)) val mt_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> GTot Type0 let mt_next_rel #hsz #f n mt nmt = hs_next_rel #hsz #f (pow2 (n-1)) mt nmt val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs)) let rec hs_next_rel_next_lv #hsz #f n hs nhs = if n = 0 then () else hs_next_rel_next_lv #_ #f (n - 1) (S.slice hs 2 (S.length hs)) (S.slice nhs 1 (S.length nhs)) val mt_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures S.equal nmt (mt_next_lv #_ #f mt)) let mt_next_rel_next_lv #hsz #f n mt nmt = hs_next_rel_next_lv #_ #f (pow2 (n-1)) mt nmt val mt_next_rel_upd_even: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i (padded_hash_fun #hsz f v (S.index mt (2 * i + 1))))) let mt_next_rel_upd_even #hsz #f n mt nmt i v = () #push-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val mt_next_rel_upd_even_pad: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash #hsz -> Lemma (requires (mt_next_rel #_ #f n mt nmt) /\ (S.index mt (2 * i + 1) == HPad)) (ensures (mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i v))) let mt_next_rel_upd_even_pad #hsz #f n mt nmt i v = () #pop-options val mt_next_rel_upd_odd: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i + 1) v) (S.upd nmt i (padded_hash_fun #_ f (S.index mt (2 * i)) v))) let mt_next_rel_upd_odd #hsz #f n mt nmt i v = () // fournet: just [root]? val mt_get_root: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> GTot (padded_hash #hsz) let rec mt_get_root #hsz #f #n mt = if n = 0 then mt.[0] else mt_get_root #_ #f (mt_next_lv #_ #f mt) #push-options "--initial_fuel 2 --max_fuel 2" val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt))) let rec mt_get_root_step #hsz #f #n mt = if n = 1 then () else begin mt_get_root_step #_ #f (mt_next_lv #_ #f mt); mt_next_lv_mt_left #_ #f mt; mt_next_lv_mt_right #_ #f mt end #pop-options type path #hsz n = S.lseq (padded_hash #hsz) n /// We first specify full paths, including padding. val mt_get_path: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> i:nat{i < pow2 n} -> GTot (path #hsz n) let rec mt_get_path #hsz #f #n t i = if n = 0 then S.empty else S.cons (if i % 2 = 0 then t.[i + 1] else t.[i - 1]) (mt_get_path #_ #f (mt_next_lv #_ #f t) (i / 2)) val mt_verify_: #hsz:pos -> #f:hash_fun_t #hsz ->#n:nat -> p:path #hsz n -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> GTot (padded_hash #hsz) let rec mt_verify_ #hsz #f #n p idx h = if n = 0 then h else mt_verify_ #_ #f #(n-1) (S.tail p) (idx / 2) (if idx % 2 = 0 then padded_hash_fun #_ f h (S.head p) else padded_hash_fun #_ f (S.head p) h) val mt_verify: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> p:(path #hsz n) -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> padded_hash #hsz -> GTot prop let mt_verify #hsz #f #n p idx h rt = rt == mt_verify_ #_ #f p idx h /// Correctness: the root of a tree is correctly recomputed from any of its paths val hs_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> hs:hashes{S.length hs = 2 * n} -> idx:nat{idx < 2 * n} -> Lemma ((hs_next_lv #_ #f #n hs).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f hs.[idx] hs.[idx + 1] else padded_hash_fun #_ f hs.[idx - 1] hs.[idx])) let rec hs_next_lv_get #hsz #f #n hs idx = if idx < 2 then () else hs_next_lv_get #_ #f #(n-1) (S.slice hs 2 (S.length hs)) (idx - 2) val mt_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> Lemma ( (mt_next_lv #_ #f mt).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f mt.[idx] mt.[idx + 1] else padded_hash_fun #_ f mt.[idx - 1] mt.[idx]))
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mt_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> Lemma ( (mt_next_lv #_ #f mt).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f mt.[idx] mt.[idx + 1] else padded_hash_fun #_ f mt.[idx - 1] mt.[idx]))
[]
MerkleTree.Spec.mt_next_lv_get
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
mt: MerkleTree.Spec.merkle_tree n -> idx: Prims.nat{idx < Prims.pow2 n} -> FStar.Pervasives.Lemma (ensures (MerkleTree.Spec.mt_next_lv mt).[ idx / 2 ] == (match idx % 2 = 0 with | true -> MerkleTree.Spec.padded_hash_fun f mt.[ idx ] mt.[ idx + 1 ] | _ -> MerkleTree.Spec.padded_hash_fun f mt.[ idx - 1 ] mt.[ idx ]))
{ "end_col": 43, "end_line": 299, "start_col": 2, "start_line": 299 }
FStar.Pervasives.Lemma
val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt)))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 mt_get_root_step #hsz #f #n mt = if n = 1 then () else begin mt_get_root_step #_ #f (mt_next_lv #_ #f mt); mt_next_lv_mt_left #_ #f mt; mt_next_lv_mt_right #_ #f mt end
val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt))) let rec mt_get_root_step #hsz #f #n mt =
false
null
true
if n = 1 then () else (mt_get_root_step #_ #f (mt_next_lv #_ #f mt); mt_next_lv_mt_left #_ #f mt; mt_next_lv_mt_right #_ #f mt)
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "lemma" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "MerkleTree.Spec.merkle_tree", "Prims.op_Equality", "Prims.int", "Prims.bool", "MerkleTree.Spec.mt_next_lv_mt_right", "Prims.unit", "MerkleTree.Spec.mt_next_lv_mt_left", "MerkleTree.Spec.mt_get_root_step", "Prims.op_Subtraction", "MerkleTree.Spec.mt_next_lv" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end val mt_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> GTot (merkle_tree #hsz (n-1)) let mt_next_lv #_ #f #n mt = hs_next_lv #_ #f #(pow2 (n-1)) mt val mt_next_lv_mt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_left mt)) (mt_left (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_left #hsz #f #n mt = hs_next_lv_slice #_ #f #(pow2 (n-1)) mt 0 (pow2 (n-2)) val mt_next_lv_mt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_right mt)) (mt_right (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_right #hsz #f #n mt = hs_next_lv_slice #hsz #f #(pow2 (n-1)) mt (pow2 (n-2)) (pow2 (n-1)) val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2))) let hs_next_lv_equiv #hsz #f j n hs1 hs2 = forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i:nat{i < j / 2}). hs1'.[i] == padded_hash_fun #hsz f hs1.[2 * i] hs1.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs2'.[i] == padded_hash_fun #hsz f hs2.[2 * i] hs2.[2 * i + 1]); assert (forall (i:nat{i < j}). (S.slice hs1 0 j).[i] == (S.slice hs2 0 j).[i]); assert (forall (i:nat{i < j}). hs1.[i] == hs2.[i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i] == hs2.[2 * i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i + 1] == hs2.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs1'.[i] == hs2'.[i]) val mt_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= pow2 n} -> mt1:merkle_tree #hsz n -> mt2:merkle_tree #hsz n -> Lemma (requires S.equal (S.slice mt1 0 j) (S.slice mt2 0 j)) (ensures S.equal (S.slice (mt_next_lv #_ #f #_ mt1) 0 (j / 2)) (S.slice (mt_next_lv #_ #f #_ mt2) 0 (j / 2))) let mt_next_lv_equiv #hsz #f j n mt1 mt2 = hs_next_lv_equiv #_ #f j (pow2 (n-1)) mt1 mt2 val hs_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> nhs:hashes #hsz {S.length nhs = n} -> GTot Type0 let hs_next_rel #hsz #f n hs nhs = forall (i:nat{i < n}). S.index nhs i == padded_hash_fun #hsz f (S.index hs (2 * i)) (S.index hs (2 * i + 1)) val mt_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> GTot Type0 let mt_next_rel #hsz #f n mt nmt = hs_next_rel #hsz #f (pow2 (n-1)) mt nmt val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs)) let rec hs_next_rel_next_lv #hsz #f n hs nhs = if n = 0 then () else hs_next_rel_next_lv #_ #f (n - 1) (S.slice hs 2 (S.length hs)) (S.slice nhs 1 (S.length nhs)) val mt_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures S.equal nmt (mt_next_lv #_ #f mt)) let mt_next_rel_next_lv #hsz #f n mt nmt = hs_next_rel_next_lv #_ #f (pow2 (n-1)) mt nmt val mt_next_rel_upd_even: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i (padded_hash_fun #hsz f v (S.index mt (2 * i + 1))))) let mt_next_rel_upd_even #hsz #f n mt nmt i v = () #push-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val mt_next_rel_upd_even_pad: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash #hsz -> Lemma (requires (mt_next_rel #_ #f n mt nmt) /\ (S.index mt (2 * i + 1) == HPad)) (ensures (mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i v))) let mt_next_rel_upd_even_pad #hsz #f n mt nmt i v = () #pop-options val mt_next_rel_upd_odd: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i + 1) v) (S.upd nmt i (padded_hash_fun #_ f (S.index mt (2 * i)) v))) let mt_next_rel_upd_odd #hsz #f n mt nmt i v = () // fournet: just [root]? val mt_get_root: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> GTot (padded_hash #hsz) let rec mt_get_root #hsz #f #n mt = if n = 0 then mt.[0] else mt_get_root #_ #f (mt_next_lv #_ #f mt) #push-options "--initial_fuel 2 --max_fuel 2" val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt)))
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt)))
[ "recursion" ]
MerkleTree.Spec.mt_get_root_step
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
mt: MerkleTree.Spec.merkle_tree n -> FStar.Pervasives.Lemma (ensures MerkleTree.Spec.mt_get_root mt == MerkleTree.Spec.padded_hash_fun f (MerkleTree.Spec.mt_get_root (MerkleTree.Spec.mt_left mt)) (MerkleTree.Spec.mt_get_root (MerkleTree.Spec.mt_right mt)))
{ "end_col": 5, "end_line": 243, "start_col": 2, "start_line": 238 }
FStar.Pervasives.Lemma
val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1])
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1)
val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i =
false
null
true
if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1)
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "lemma" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "MerkleTree.Spec.hashes", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "MerkleTree.Spec.padded_hash", "FStar.Mul.op_Star", "Prims.op_LessThan", "Prims.op_BarBar", "Prims.bool", "MerkleTree.Spec.hs_next_lv_index", "Prims.op_Subtraction", "FStar.Seq.Base.slice", "Prims.unit" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1])
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1])
[ "recursion" ]
MerkleTree.Spec.hs_next_lv_index
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
hs: MerkleTree.Spec.hashes{FStar.Seq.Base.length hs = 2 * n} -> i: Prims.nat{i < n} -> FStar.Pervasives.Lemma (ensures (MerkleTree.Spec.hs_next_lv hs).[ i ] == MerkleTree.Spec.padded_hash_fun f hs.[ 2 * i ] hs.[ 2 * i + 1 ])
{ "end_col": 77, "end_line": 78, "start_col": 2, "start_line": 77 }
FStar.Pervasives.Lemma
val mt_get_root_pad_index_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> Lemma (HPad? mt.[0] <==> HPad? (mt_get_root #_ #f mt))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 mt_get_root_pad_index_0 #hsz #f #n (mt:merkle_tree #hsz n) = if n = 0 then () else let mt:merkle_tree #hsz (n-1) = mt_next_lv #_ #f #n mt in mt_get_root_pad_index_0 #_ #f #(n-1) mt
val mt_get_root_pad_index_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> Lemma (HPad? mt.[0] <==> HPad? (mt_get_root #_ #f mt)) let rec mt_get_root_pad_index_0 #hsz #f #n (mt: merkle_tree #hsz n) =
false
null
true
if n = 0 then () else let mt:merkle_tree #hsz (n - 1) = mt_next_lv #_ #f #n mt in mt_get_root_pad_index_0 #_ #f #(n - 1) mt
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "lemma" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "MerkleTree.Spec.merkle_tree", "Prims.op_Equality", "Prims.int", "Prims.bool", "MerkleTree.Spec.mt_get_root_pad_index_0", "Prims.op_Subtraction", "MerkleTree.Spec.mt_next_lv", "Prims.unit" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end val mt_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> GTot (merkle_tree #hsz (n-1)) let mt_next_lv #_ #f #n mt = hs_next_lv #_ #f #(pow2 (n-1)) mt val mt_next_lv_mt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_left mt)) (mt_left (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_left #hsz #f #n mt = hs_next_lv_slice #_ #f #(pow2 (n-1)) mt 0 (pow2 (n-2)) val mt_next_lv_mt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_right mt)) (mt_right (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_right #hsz #f #n mt = hs_next_lv_slice #hsz #f #(pow2 (n-1)) mt (pow2 (n-2)) (pow2 (n-1)) val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2))) let hs_next_lv_equiv #hsz #f j n hs1 hs2 = forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i:nat{i < j / 2}). hs1'.[i] == padded_hash_fun #hsz f hs1.[2 * i] hs1.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs2'.[i] == padded_hash_fun #hsz f hs2.[2 * i] hs2.[2 * i + 1]); assert (forall (i:nat{i < j}). (S.slice hs1 0 j).[i] == (S.slice hs2 0 j).[i]); assert (forall (i:nat{i < j}). hs1.[i] == hs2.[i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i] == hs2.[2 * i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i + 1] == hs2.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs1'.[i] == hs2'.[i]) val mt_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= pow2 n} -> mt1:merkle_tree #hsz n -> mt2:merkle_tree #hsz n -> Lemma (requires S.equal (S.slice mt1 0 j) (S.slice mt2 0 j)) (ensures S.equal (S.slice (mt_next_lv #_ #f #_ mt1) 0 (j / 2)) (S.slice (mt_next_lv #_ #f #_ mt2) 0 (j / 2))) let mt_next_lv_equiv #hsz #f j n mt1 mt2 = hs_next_lv_equiv #_ #f j (pow2 (n-1)) mt1 mt2 val hs_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> nhs:hashes #hsz {S.length nhs = n} -> GTot Type0 let hs_next_rel #hsz #f n hs nhs = forall (i:nat{i < n}). S.index nhs i == padded_hash_fun #hsz f (S.index hs (2 * i)) (S.index hs (2 * i + 1)) val mt_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> GTot Type0 let mt_next_rel #hsz #f n mt nmt = hs_next_rel #hsz #f (pow2 (n-1)) mt nmt val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs)) let rec hs_next_rel_next_lv #hsz #f n hs nhs = if n = 0 then () else hs_next_rel_next_lv #_ #f (n - 1) (S.slice hs 2 (S.length hs)) (S.slice nhs 1 (S.length nhs)) val mt_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures S.equal nmt (mt_next_lv #_ #f mt)) let mt_next_rel_next_lv #hsz #f n mt nmt = hs_next_rel_next_lv #_ #f (pow2 (n-1)) mt nmt val mt_next_rel_upd_even: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i (padded_hash_fun #hsz f v (S.index mt (2 * i + 1))))) let mt_next_rel_upd_even #hsz #f n mt nmt i v = () #push-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val mt_next_rel_upd_even_pad: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash #hsz -> Lemma (requires (mt_next_rel #_ #f n mt nmt) /\ (S.index mt (2 * i + 1) == HPad)) (ensures (mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i v))) let mt_next_rel_upd_even_pad #hsz #f n mt nmt i v = () #pop-options val mt_next_rel_upd_odd: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i + 1) v) (S.upd nmt i (padded_hash_fun #_ f (S.index mt (2 * i)) v))) let mt_next_rel_upd_odd #hsz #f n mt nmt i v = () // fournet: just [root]? val mt_get_root: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> GTot (padded_hash #hsz) let rec mt_get_root #hsz #f #n mt = if n = 0 then mt.[0] else mt_get_root #_ #f (mt_next_lv #_ #f mt) #push-options "--initial_fuel 2 --max_fuel 2" val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt))) let rec mt_get_root_step #hsz #f #n mt = if n = 1 then () else begin mt_get_root_step #_ #f (mt_next_lv #_ #f mt); mt_next_lv_mt_left #_ #f mt; mt_next_lv_mt_right #_ #f mt end #pop-options type path #hsz n = S.lseq (padded_hash #hsz) n /// We first specify full paths, including padding. val mt_get_path: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> i:nat{i < pow2 n} -> GTot (path #hsz n) let rec mt_get_path #hsz #f #n t i = if n = 0 then S.empty else S.cons (if i % 2 = 0 then t.[i + 1] else t.[i - 1]) (mt_get_path #_ #f (mt_next_lv #_ #f t) (i / 2)) val mt_verify_: #hsz:pos -> #f:hash_fun_t #hsz ->#n:nat -> p:path #hsz n -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> GTot (padded_hash #hsz) let rec mt_verify_ #hsz #f #n p idx h = if n = 0 then h else mt_verify_ #_ #f #(n-1) (S.tail p) (idx / 2) (if idx % 2 = 0 then padded_hash_fun #_ f h (S.head p) else padded_hash_fun #_ f (S.head p) h) val mt_verify: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> p:(path #hsz n) -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> padded_hash #hsz -> GTot prop let mt_verify #hsz #f #n p idx h rt = rt == mt_verify_ #_ #f p idx h /// Correctness: the root of a tree is correctly recomputed from any of its paths val hs_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> hs:hashes{S.length hs = 2 * n} -> idx:nat{idx < 2 * n} -> Lemma ((hs_next_lv #_ #f #n hs).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f hs.[idx] hs.[idx + 1] else padded_hash_fun #_ f hs.[idx - 1] hs.[idx])) let rec hs_next_lv_get #hsz #f #n hs idx = if idx < 2 then () else hs_next_lv_get #_ #f #(n-1) (S.slice hs 2 (S.length hs)) (idx - 2) val mt_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> Lemma ( (mt_next_lv #_ #f mt).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f mt.[idx] mt.[idx + 1] else padded_hash_fun #_ f mt.[idx - 1] mt.[idx])) let mt_next_lv_get #hsz #f #n mt idx = hs_next_lv_get #_ #f #(pow2 (n-1)) mt idx val mt_get_path_ok_: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> t:merkle_tree #hsz n -> i:nat{i < pow2 n} -> Lemma (mt_verify_ #_ #f (mt_get_path #_ #f t i) i (mt_get t i) == mt_get_root #_ #f t) let rec mt_get_path_ok_ #hsz #f #n mt idx = if n = 0 then () else begin assert (S.head (mt_get_path #_ #f mt idx) == (if idx % 2 = 0 then mt.[idx + 1] else mt.[idx - 1])); assert (S.equal (S.tail (mt_get_path #_ #f mt idx)) (mt_get_path #_ #f (mt_next_lv #_ #f mt) (idx / 2))); mt_get_path_ok_ #_ #f (mt_next_lv #_ #f mt) (idx / 2); mt_next_lv_get #_ #f mt idx end /// Security: we reduce tree collisions to collisions on the hash /// compression function. Such collisions yield collisions on the SHA2 /// standard (by adding the same length and padding to the /// accumulators). /// /// One complication addressed in the proof is the handling of /// implicit padding. /// All hashes in a sequence are raw hashes, not padding val raw_hashes: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes #hsz -> Tot Type0 (decreases (S.length hs)) let rec raw_hashes #hsz #f hs = if S.length hs = 0 then True else (HRaw? (S.head hs) /\ raw_hashes #_ #f (S.tail hs)) val raw_hashes_raws: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes{raw_hashes #hsz #f hs} -> Tot (S.seq (hash #hsz)) (decreases (S.length hs)) let rec raw_hashes_raws #hsz #f hs = if S.length hs = 0 then S.empty else S.cons (HRaw?.hr (S.head hs)) (raw_hashes_raws #_ #f (S.tail hs)) val raw_hashes_index: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat{i < S.length hs} -> Lemma (requires raw_hashes #_ #f hs) (ensures HRaw? #hsz hs.[i]) (decreases i) let rec raw_hashes_index #hsz #f hs i = if i = 0 then () else raw_hashes_index #_ #f (S.tail hs) (i - 1) val raw_hashes_slice: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat -> j:nat{i <= j && j <= S.length hs} -> Lemma (requires raw_hashes #_ #f hs) (ensures raw_hashes #_ #f (S.slice hs i j)) (decreases (j - i)) let rec raw_hashes_slice #hsz #f hs i j = if i = j then () else ( raw_hashes_index #_ #f hs i; raw_hashes_slice #_ #f hs (i + 1) j) /// All hashes in a sequence are just padding val pad_hashes: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes #hsz -> Type0 let pad_hashes #hsz #f hs = S.equal hs (S.create (S.length hs) HPad) val pad_hashes_slice: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat -> j:nat{i <= j && j <= S.length hs} -> Lemma (requires pad_hashes #_ #f hs) (ensures pad_hashes #_ #f (S.slice hs i j)) (decreases (j - i)) let rec pad_hashes_slice #hsz #f hs i j = if i = j then () else pad_hashes_slice #_ #f hs (i + 1) j /// Right-padded Merkle tree, a tree refinement let rpmt (#hsz:pos) (#f:hash_fun_t) (n:nat) (i:nat{i <= pow2 n}) = mt:merkle_tree #hsz n { raw_hashes #_ #f (S.slice mt 0 i) /\ pad_hashes #_ #f (S.slice mt i (S.length mt)) } val rpmt_raws: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #hsz #f n i -> S.seq (hash #hsz) let rpmt_raws #hsz #f #n #i mt = raw_hashes_raws #_ #f (S.slice mt 0 i) val rpmt_i_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:rpmt #hsz #f n 0 -> Lemma (S.equal mt (S.create (pow2 n) (HPad #hsz))) let rpmt_i_0 #hsz #f #n mt = () val rpmt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #hsz #f (n-1) (if i <= pow2 (n-1) then i else pow2 (n-1)) let rpmt_left #hsz #f #n #i mt = if i <= pow2 (n-1) then pad_hashes_slice #_ #f (S.slice mt i (S.length mt)) 0 (pow2 (n-1) - i) else raw_hashes_slice #_ #f (S.slice mt 0 i) 0 (pow2 (n-1)); mt_left mt #push-options "--z3rlimit 40" val rpmt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #_ #f (n-1) (if i <= pow2 (n-1) then 0 else i - pow2 (n-1)) let rpmt_right #hsz #f #n #i mt = if i <= pow2 (n-1) then pad_hashes_slice #_ #f (S.slice mt i (S.length mt)) (pow2 (n-1) - i) (pow2 n - i) else raw_hashes_slice #_ #f (S.slice mt 0 i) (pow2 (n-1)) i; mt_right mt /// Two right-padded Merkle trees collide when /// 1) they have the same height (`n`) and number of raw hashes (`i`), /// 2) their contents differ, and /// 3) their roots are same. // fournet: we may want to work towards removing 1) using a hash prefix noeq type mt_collide (#hsz:pos) (#f:hash_fun_t #hsz) (n:nat) (i:nat{i <= pow2 n}) = | Collision: mt1:rpmt #_ #f n i -> mt2:rpmt #_ #f n i { mt1 =!= mt2 /\ mt_get_root #_ #f #_ mt1 == mt_get_root #_ #f #_ mt2 } -> mt_collide #_ #f n i noeq type hash2_raw_collide = | Collision2: #hsz:pos -> #f:hash_fun_t #hsz -> lh1:hash -> rh1:hash -> lh2:hash -> rh2:hash { (lh1 =!= lh2 \/ rh1 =!= rh2) /\ f lh1 rh1 == f lh2 rh2 } -> hash2_raw_collide /// Auxiliary lemmas for the proof val rpmt_pad_hashes_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #_ #f n i -> Lemma (i = 0 <==> pad_hashes #_ #f mt ) let rpmt_pad_hashes_0 #_ #_ #n #i mt = () val rpmt_pad_hashes_index_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #_ #f n i -> Lemma (pad_hashes #_ #f mt <==> HPad? mt.[0]) let rpmt_pad_hashes_index_0 #_ #_ #n #i mt = () val mt_get_root_pad_index_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> Lemma (HPad? mt.[0] <==> HPad? (mt_get_root #_ #f mt))
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mt_get_root_pad_index_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> Lemma (HPad? mt.[0] <==> HPad? (mt_get_root #_ #f mt))
[ "recursion" ]
MerkleTree.Spec.mt_get_root_pad_index_0
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
mt: MerkleTree.Spec.merkle_tree n -> FStar.Pervasives.Lemma (ensures HPad? mt.[ 0 ] <==> HPad? (MerkleTree.Spec.mt_get_root mt))
{ "end_col": 43, "end_line": 455, "start_col": 2, "start_line": 452 }
Prims.Tot
val rpmt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #hsz #f (n-1) (if i <= pow2 (n-1) then i else pow2 (n-1))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 rpmt_left #hsz #f #n #i mt = if i <= pow2 (n-1) then pad_hashes_slice #_ #f (S.slice mt i (S.length mt)) 0 (pow2 (n-1) - i) else raw_hashes_slice #_ #f (S.slice mt 0 i) 0 (pow2 (n-1)); mt_left mt
val rpmt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #hsz #f (n-1) (if i <= pow2 (n-1) then i else pow2 (n-1)) let rpmt_left #hsz #f #n #i mt =
false
null
false
if i <= pow2 (n - 1) then pad_hashes_slice #_ #f (S.slice mt i (S.length mt)) 0 (pow2 (n - 1) - i) else raw_hashes_slice #_ #f (S.slice mt 0 i) 0 (pow2 (n - 1)); mt_left mt
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "total" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.pow2", "MerkleTree.Spec.rpmt", "MerkleTree.Spec.mt_left", "Prims.unit", "Prims.op_Subtraction", "MerkleTree.Spec.pad_hashes_slice", "FStar.Seq.Base.slice", "MerkleTree.Spec.padded_hash", "FStar.Seq.Base.length", "Prims.bool", "MerkleTree.Spec.raw_hashes_slice" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end val mt_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> GTot (merkle_tree #hsz (n-1)) let mt_next_lv #_ #f #n mt = hs_next_lv #_ #f #(pow2 (n-1)) mt val mt_next_lv_mt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_left mt)) (mt_left (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_left #hsz #f #n mt = hs_next_lv_slice #_ #f #(pow2 (n-1)) mt 0 (pow2 (n-2)) val mt_next_lv_mt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_right mt)) (mt_right (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_right #hsz #f #n mt = hs_next_lv_slice #hsz #f #(pow2 (n-1)) mt (pow2 (n-2)) (pow2 (n-1)) val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2))) let hs_next_lv_equiv #hsz #f j n hs1 hs2 = forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i:nat{i < j / 2}). hs1'.[i] == padded_hash_fun #hsz f hs1.[2 * i] hs1.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs2'.[i] == padded_hash_fun #hsz f hs2.[2 * i] hs2.[2 * i + 1]); assert (forall (i:nat{i < j}). (S.slice hs1 0 j).[i] == (S.slice hs2 0 j).[i]); assert (forall (i:nat{i < j}). hs1.[i] == hs2.[i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i] == hs2.[2 * i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i + 1] == hs2.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs1'.[i] == hs2'.[i]) val mt_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= pow2 n} -> mt1:merkle_tree #hsz n -> mt2:merkle_tree #hsz n -> Lemma (requires S.equal (S.slice mt1 0 j) (S.slice mt2 0 j)) (ensures S.equal (S.slice (mt_next_lv #_ #f #_ mt1) 0 (j / 2)) (S.slice (mt_next_lv #_ #f #_ mt2) 0 (j / 2))) let mt_next_lv_equiv #hsz #f j n mt1 mt2 = hs_next_lv_equiv #_ #f j (pow2 (n-1)) mt1 mt2 val hs_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> nhs:hashes #hsz {S.length nhs = n} -> GTot Type0 let hs_next_rel #hsz #f n hs nhs = forall (i:nat{i < n}). S.index nhs i == padded_hash_fun #hsz f (S.index hs (2 * i)) (S.index hs (2 * i + 1)) val mt_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> GTot Type0 let mt_next_rel #hsz #f n mt nmt = hs_next_rel #hsz #f (pow2 (n-1)) mt nmt val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs)) let rec hs_next_rel_next_lv #hsz #f n hs nhs = if n = 0 then () else hs_next_rel_next_lv #_ #f (n - 1) (S.slice hs 2 (S.length hs)) (S.slice nhs 1 (S.length nhs)) val mt_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures S.equal nmt (mt_next_lv #_ #f mt)) let mt_next_rel_next_lv #hsz #f n mt nmt = hs_next_rel_next_lv #_ #f (pow2 (n-1)) mt nmt val mt_next_rel_upd_even: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i (padded_hash_fun #hsz f v (S.index mt (2 * i + 1))))) let mt_next_rel_upd_even #hsz #f n mt nmt i v = () #push-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val mt_next_rel_upd_even_pad: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash #hsz -> Lemma (requires (mt_next_rel #_ #f n mt nmt) /\ (S.index mt (2 * i + 1) == HPad)) (ensures (mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i v))) let mt_next_rel_upd_even_pad #hsz #f n mt nmt i v = () #pop-options val mt_next_rel_upd_odd: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i + 1) v) (S.upd nmt i (padded_hash_fun #_ f (S.index mt (2 * i)) v))) let mt_next_rel_upd_odd #hsz #f n mt nmt i v = () // fournet: just [root]? val mt_get_root: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> GTot (padded_hash #hsz) let rec mt_get_root #hsz #f #n mt = if n = 0 then mt.[0] else mt_get_root #_ #f (mt_next_lv #_ #f mt) #push-options "--initial_fuel 2 --max_fuel 2" val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt))) let rec mt_get_root_step #hsz #f #n mt = if n = 1 then () else begin mt_get_root_step #_ #f (mt_next_lv #_ #f mt); mt_next_lv_mt_left #_ #f mt; mt_next_lv_mt_right #_ #f mt end #pop-options type path #hsz n = S.lseq (padded_hash #hsz) n /// We first specify full paths, including padding. val mt_get_path: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> i:nat{i < pow2 n} -> GTot (path #hsz n) let rec mt_get_path #hsz #f #n t i = if n = 0 then S.empty else S.cons (if i % 2 = 0 then t.[i + 1] else t.[i - 1]) (mt_get_path #_ #f (mt_next_lv #_ #f t) (i / 2)) val mt_verify_: #hsz:pos -> #f:hash_fun_t #hsz ->#n:nat -> p:path #hsz n -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> GTot (padded_hash #hsz) let rec mt_verify_ #hsz #f #n p idx h = if n = 0 then h else mt_verify_ #_ #f #(n-1) (S.tail p) (idx / 2) (if idx % 2 = 0 then padded_hash_fun #_ f h (S.head p) else padded_hash_fun #_ f (S.head p) h) val mt_verify: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> p:(path #hsz n) -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> padded_hash #hsz -> GTot prop let mt_verify #hsz #f #n p idx h rt = rt == mt_verify_ #_ #f p idx h /// Correctness: the root of a tree is correctly recomputed from any of its paths val hs_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> hs:hashes{S.length hs = 2 * n} -> idx:nat{idx < 2 * n} -> Lemma ((hs_next_lv #_ #f #n hs).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f hs.[idx] hs.[idx + 1] else padded_hash_fun #_ f hs.[idx - 1] hs.[idx])) let rec hs_next_lv_get #hsz #f #n hs idx = if idx < 2 then () else hs_next_lv_get #_ #f #(n-1) (S.slice hs 2 (S.length hs)) (idx - 2) val mt_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> Lemma ( (mt_next_lv #_ #f mt).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f mt.[idx] mt.[idx + 1] else padded_hash_fun #_ f mt.[idx - 1] mt.[idx])) let mt_next_lv_get #hsz #f #n mt idx = hs_next_lv_get #_ #f #(pow2 (n-1)) mt idx val mt_get_path_ok_: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> t:merkle_tree #hsz n -> i:nat{i < pow2 n} -> Lemma (mt_verify_ #_ #f (mt_get_path #_ #f t i) i (mt_get t i) == mt_get_root #_ #f t) let rec mt_get_path_ok_ #hsz #f #n mt idx = if n = 0 then () else begin assert (S.head (mt_get_path #_ #f mt idx) == (if idx % 2 = 0 then mt.[idx + 1] else mt.[idx - 1])); assert (S.equal (S.tail (mt_get_path #_ #f mt idx)) (mt_get_path #_ #f (mt_next_lv #_ #f mt) (idx / 2))); mt_get_path_ok_ #_ #f (mt_next_lv #_ #f mt) (idx / 2); mt_next_lv_get #_ #f mt idx end /// Security: we reduce tree collisions to collisions on the hash /// compression function. Such collisions yield collisions on the SHA2 /// standard (by adding the same length and padding to the /// accumulators). /// /// One complication addressed in the proof is the handling of /// implicit padding. /// All hashes in a sequence are raw hashes, not padding val raw_hashes: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes #hsz -> Tot Type0 (decreases (S.length hs)) let rec raw_hashes #hsz #f hs = if S.length hs = 0 then True else (HRaw? (S.head hs) /\ raw_hashes #_ #f (S.tail hs)) val raw_hashes_raws: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes{raw_hashes #hsz #f hs} -> Tot (S.seq (hash #hsz)) (decreases (S.length hs)) let rec raw_hashes_raws #hsz #f hs = if S.length hs = 0 then S.empty else S.cons (HRaw?.hr (S.head hs)) (raw_hashes_raws #_ #f (S.tail hs)) val raw_hashes_index: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat{i < S.length hs} -> Lemma (requires raw_hashes #_ #f hs) (ensures HRaw? #hsz hs.[i]) (decreases i) let rec raw_hashes_index #hsz #f hs i = if i = 0 then () else raw_hashes_index #_ #f (S.tail hs) (i - 1) val raw_hashes_slice: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat -> j:nat{i <= j && j <= S.length hs} -> Lemma (requires raw_hashes #_ #f hs) (ensures raw_hashes #_ #f (S.slice hs i j)) (decreases (j - i)) let rec raw_hashes_slice #hsz #f hs i j = if i = j then () else ( raw_hashes_index #_ #f hs i; raw_hashes_slice #_ #f hs (i + 1) j) /// All hashes in a sequence are just padding val pad_hashes: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes #hsz -> Type0 let pad_hashes #hsz #f hs = S.equal hs (S.create (S.length hs) HPad) val pad_hashes_slice: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat -> j:nat{i <= j && j <= S.length hs} -> Lemma (requires pad_hashes #_ #f hs) (ensures pad_hashes #_ #f (S.slice hs i j)) (decreases (j - i)) let rec pad_hashes_slice #hsz #f hs i j = if i = j then () else pad_hashes_slice #_ #f hs (i + 1) j /// Right-padded Merkle tree, a tree refinement let rpmt (#hsz:pos) (#f:hash_fun_t) (n:nat) (i:nat{i <= pow2 n}) = mt:merkle_tree #hsz n { raw_hashes #_ #f (S.slice mt 0 i) /\ pad_hashes #_ #f (S.slice mt i (S.length mt)) } val rpmt_raws: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #hsz #f n i -> S.seq (hash #hsz) let rpmt_raws #hsz #f #n #i mt = raw_hashes_raws #_ #f (S.slice mt 0 i) val rpmt_i_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:rpmt #hsz #f n 0 -> Lemma (S.equal mt (S.create (pow2 n) (HPad #hsz))) let rpmt_i_0 #hsz #f #n mt = () val rpmt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #hsz #f (n-1) (if i <= pow2 (n-1) then i else pow2 (n-1))
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rpmt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #hsz #f (n-1) (if i <= pow2 (n-1) then i else pow2 (n-1))
[]
MerkleTree.Spec.rpmt_left
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
mt: MerkleTree.Spec.rpmt n i -> MerkleTree.Spec.rpmt (n - 1) (match i <= Prims.pow2 (n - 1) with | true -> i | _ -> Prims.pow2 (n - 1))
{ "end_col": 12, "end_line": 400, "start_col": 2, "start_line": 397 }
FStar.Pervasives.Lemma
val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2)))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 hs_next_lv_equiv #hsz #f j n hs1 hs2 = forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i:nat{i < j / 2}). hs1'.[i] == padded_hash_fun #hsz f hs1.[2 * i] hs1.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs2'.[i] == padded_hash_fun #hsz f hs2.[2 * i] hs2.[2 * i + 1]); assert (forall (i:nat{i < j}). (S.slice hs1 0 j).[i] == (S.slice hs2 0 j).[i]); assert (forall (i:nat{i < j}). hs1.[i] == hs2.[i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i] == hs2.[2 * i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i + 1] == hs2.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs1'.[i] == hs2'.[i])
val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2))) let hs_next_lv_equiv #hsz #f j n hs1 hs2 =
false
null
true
forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i: nat{i < j / 2}). hs1'.[ i ] == padded_hash_fun #hsz f hs1.[ 2 * i ] hs1.[ 2 * i + 1 ]); assert (forall (i: nat{i < j / 2}). hs2'.[ i ] == padded_hash_fun #hsz f hs2.[ 2 * i ] hs2.[ 2 * i + 1 ]); assert (forall (i: nat{i < j}). (S.slice hs1 0 j).[ i ] == (S.slice hs2 0 j).[ i ]); assert (forall (i: nat{i < j}). hs1.[ i ] == hs2.[ i ]); assert (forall (i: nat{i < j / 2}). hs1.[ 2 * i ] == hs2.[ 2 * i ]); assert (forall (i: nat{i < j / 2}). hs1.[ 2 * i + 1 ] == hs2.[ 2 * i + 1 ]); assert (forall (i: nat{i < j / 2}). hs1'.[ i ] == hs2'.[ i ])
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "lemma" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "MerkleTree.Spec.hashes", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "MerkleTree.Spec.padded_hash", "Prims._assert", "Prims.l_Forall", "Prims.op_LessThan", "Prims.op_Division", "Prims.eq2", "MerkleTree.Spec.op_String_Access", "Prims.unit", "Prims.op_Addition", "FStar.Seq.Base.slice", "MerkleTree.Spec.padded_hash_fun", "MerkleTree.Spec.hs_next_lv", "FStar.Classical.forall_intro", "MerkleTree.Spec.hs_next_lv_index" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end val mt_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> GTot (merkle_tree #hsz (n-1)) let mt_next_lv #_ #f #n mt = hs_next_lv #_ #f #(pow2 (n-1)) mt val mt_next_lv_mt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_left mt)) (mt_left (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_left #hsz #f #n mt = hs_next_lv_slice #_ #f #(pow2 (n-1)) mt 0 (pow2 (n-2)) val mt_next_lv_mt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_right mt)) (mt_right (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_right #hsz #f #n mt = hs_next_lv_slice #hsz #f #(pow2 (n-1)) mt (pow2 (n-2)) (pow2 (n-1)) val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2)))
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2)))
[]
MerkleTree.Spec.hs_next_lv_equiv
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
j: Prims.nat -> n: Prims.pos{j <= 2 * n} -> hs1: MerkleTree.Spec.hashes{FStar.Seq.Base.length hs1 = 2 * n} -> hs2: MerkleTree.Spec.hashes{FStar.Seq.Base.length hs2 = 2 * n} -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.equal (FStar.Seq.Base.slice hs1 0 j) (FStar.Seq.Base.slice hs2 0 j)) (ensures FStar.Seq.Base.equal (FStar.Seq.Base.slice (MerkleTree.Spec.hs_next_lv hs1) 0 (j / 2)) (FStar.Seq.Base.slice (MerkleTree.Spec.hs_next_lv hs2) 0 (j / 2)))
{ "end_col": 58, "end_line": 130, "start_col": 2, "start_line": 120 }
FStar.Pervasives.Lemma
val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 hs_next_rel_next_lv #hsz #f n hs nhs = if n = 0 then () else hs_next_rel_next_lv #_ #f (n - 1) (S.slice hs 2 (S.length hs)) (S.slice nhs 1 (S.length nhs))
val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs)) let rec hs_next_rel_next_lv #hsz #f n hs nhs =
false
null
true
if n = 0 then () else hs_next_rel_next_lv #_ #f (n - 1) (S.slice hs 2 (S.length hs)) (S.slice nhs 1 (S.length nhs))
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "lemma" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "MerkleTree.Spec.hashes", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "MerkleTree.Spec.padded_hash", "FStar.Mul.op_Star", "Prims.bool", "MerkleTree.Spec.hs_next_rel_next_lv", "Prims.op_Subtraction", "FStar.Seq.Base.slice", "Prims.unit" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end val mt_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> GTot (merkle_tree #hsz (n-1)) let mt_next_lv #_ #f #n mt = hs_next_lv #_ #f #(pow2 (n-1)) mt val mt_next_lv_mt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_left mt)) (mt_left (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_left #hsz #f #n mt = hs_next_lv_slice #_ #f #(pow2 (n-1)) mt 0 (pow2 (n-2)) val mt_next_lv_mt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_right mt)) (mt_right (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_right #hsz #f #n mt = hs_next_lv_slice #hsz #f #(pow2 (n-1)) mt (pow2 (n-2)) (pow2 (n-1)) val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2))) let hs_next_lv_equiv #hsz #f j n hs1 hs2 = forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i:nat{i < j / 2}). hs1'.[i] == padded_hash_fun #hsz f hs1.[2 * i] hs1.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs2'.[i] == padded_hash_fun #hsz f hs2.[2 * i] hs2.[2 * i + 1]); assert (forall (i:nat{i < j}). (S.slice hs1 0 j).[i] == (S.slice hs2 0 j).[i]); assert (forall (i:nat{i < j}). hs1.[i] == hs2.[i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i] == hs2.[2 * i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i + 1] == hs2.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs1'.[i] == hs2'.[i]) val mt_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= pow2 n} -> mt1:merkle_tree #hsz n -> mt2:merkle_tree #hsz n -> Lemma (requires S.equal (S.slice mt1 0 j) (S.slice mt2 0 j)) (ensures S.equal (S.slice (mt_next_lv #_ #f #_ mt1) 0 (j / 2)) (S.slice (mt_next_lv #_ #f #_ mt2) 0 (j / 2))) let mt_next_lv_equiv #hsz #f j n mt1 mt2 = hs_next_lv_equiv #_ #f j (pow2 (n-1)) mt1 mt2 val hs_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> nhs:hashes #hsz {S.length nhs = n} -> GTot Type0 let hs_next_rel #hsz #f n hs nhs = forall (i:nat{i < n}). S.index nhs i == padded_hash_fun #hsz f (S.index hs (2 * i)) (S.index hs (2 * i + 1)) val mt_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> GTot Type0 let mt_next_rel #hsz #f n mt nmt = hs_next_rel #hsz #f (pow2 (n-1)) mt nmt val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs))
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs))
[ "recursion" ]
MerkleTree.Spec.hs_next_rel_next_lv
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
n: Prims.nat -> hs: MerkleTree.Spec.hashes{FStar.Seq.Base.length hs = 2 * n} -> nhs: MerkleTree.Spec.hashes{FStar.Seq.Base.length nhs = n} -> FStar.Pervasives.Lemma (requires MerkleTree.Spec.hs_next_rel n hs nhs) (ensures FStar.Seq.Base.equal nhs (MerkleTree.Spec.hs_next_lv hs))
{ "end_col": 39, "end_line": 173, "start_col": 2, "start_line": 170 }
FStar.Pervasives.Lemma
val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end
val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j =
false
null
true
if i = j then () else let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[ 0 ] x.[ 1 ]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "lemma", "" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "MerkleTree.Spec.hashes", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "MerkleTree.Spec.padded_hash", "FStar.Mul.op_Star", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Prims.bool", "MerkleTree.Spec.hs_next_lv_index", "Prims.unit", "MerkleTree.Spec.hs_next_lv_slice", "Prims.op_Addition", "Prims._assert", "FStar.Seq.Base.equal", "MerkleTree.Spec.hs_next_lv", "Prims.op_Subtraction", "FStar.Seq.Properties.cons", "MerkleTree.Spec.padded_hash_fun", "MerkleTree.Spec.op_String_Access", "FStar.Seq.Base.slice", "FStar.Seq.Base.seq" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i))
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i))
[ "recursion" ]
MerkleTree.Spec.hs_next_lv_slice
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
hs: MerkleTree.Spec.hashes{FStar.Seq.Base.length hs = 2 * n} -> i: Prims.nat -> j: Prims.nat{i <= j && j <= n} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.equal (MerkleTree.Spec.hs_next_lv (FStar.Seq.Base.slice hs (2 * i) (2 * j))) (FStar.Seq.Base.slice (MerkleTree.Spec.hs_next_lv hs) i j)) (decreases j - i)
{ "end_col": 5, "end_line": 96, "start_col": 2, "start_line": 88 }
FStar.Pervasives.Lemma
val hs_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> hs:hashes{S.length hs = 2 * n} -> idx:nat{idx < 2 * n} -> Lemma ((hs_next_lv #_ #f #n hs).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f hs.[idx] hs.[idx + 1] else padded_hash_fun #_ f hs.[idx - 1] hs.[idx]))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 hs_next_lv_get #hsz #f #n hs idx = if idx < 2 then () else hs_next_lv_get #_ #f #(n-1) (S.slice hs 2 (S.length hs)) (idx - 2)
val hs_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> hs:hashes{S.length hs = 2 * n} -> idx:nat{idx < 2 * n} -> Lemma ((hs_next_lv #_ #f #n hs).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f hs.[idx] hs.[idx + 1] else padded_hash_fun #_ f hs.[idx - 1] hs.[idx])) let rec hs_next_lv_get #hsz #f #n hs idx =
false
null
true
if idx < 2 then () else hs_next_lv_get #_ #f #(n - 1) (S.slice hs 2 (S.length hs)) (idx - 2)
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "lemma" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "MerkleTree.Spec.hashes", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "MerkleTree.Spec.padded_hash", "FStar.Mul.op_Star", "Prims.nat", "Prims.op_LessThan", "Prims.bool", "MerkleTree.Spec.hs_next_lv_get", "Prims.op_Subtraction", "FStar.Seq.Base.slice", "Prims.unit" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end val mt_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> GTot (merkle_tree #hsz (n-1)) let mt_next_lv #_ #f #n mt = hs_next_lv #_ #f #(pow2 (n-1)) mt val mt_next_lv_mt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_left mt)) (mt_left (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_left #hsz #f #n mt = hs_next_lv_slice #_ #f #(pow2 (n-1)) mt 0 (pow2 (n-2)) val mt_next_lv_mt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_right mt)) (mt_right (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_right #hsz #f #n mt = hs_next_lv_slice #hsz #f #(pow2 (n-1)) mt (pow2 (n-2)) (pow2 (n-1)) val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2))) let hs_next_lv_equiv #hsz #f j n hs1 hs2 = forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i:nat{i < j / 2}). hs1'.[i] == padded_hash_fun #hsz f hs1.[2 * i] hs1.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs2'.[i] == padded_hash_fun #hsz f hs2.[2 * i] hs2.[2 * i + 1]); assert (forall (i:nat{i < j}). (S.slice hs1 0 j).[i] == (S.slice hs2 0 j).[i]); assert (forall (i:nat{i < j}). hs1.[i] == hs2.[i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i] == hs2.[2 * i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i + 1] == hs2.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs1'.[i] == hs2'.[i]) val mt_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= pow2 n} -> mt1:merkle_tree #hsz n -> mt2:merkle_tree #hsz n -> Lemma (requires S.equal (S.slice mt1 0 j) (S.slice mt2 0 j)) (ensures S.equal (S.slice (mt_next_lv #_ #f #_ mt1) 0 (j / 2)) (S.slice (mt_next_lv #_ #f #_ mt2) 0 (j / 2))) let mt_next_lv_equiv #hsz #f j n mt1 mt2 = hs_next_lv_equiv #_ #f j (pow2 (n-1)) mt1 mt2 val hs_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> nhs:hashes #hsz {S.length nhs = n} -> GTot Type0 let hs_next_rel #hsz #f n hs nhs = forall (i:nat{i < n}). S.index nhs i == padded_hash_fun #hsz f (S.index hs (2 * i)) (S.index hs (2 * i + 1)) val mt_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> GTot Type0 let mt_next_rel #hsz #f n mt nmt = hs_next_rel #hsz #f (pow2 (n-1)) mt nmt val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs)) let rec hs_next_rel_next_lv #hsz #f n hs nhs = if n = 0 then () else hs_next_rel_next_lv #_ #f (n - 1) (S.slice hs 2 (S.length hs)) (S.slice nhs 1 (S.length nhs)) val mt_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures S.equal nmt (mt_next_lv #_ #f mt)) let mt_next_rel_next_lv #hsz #f n mt nmt = hs_next_rel_next_lv #_ #f (pow2 (n-1)) mt nmt val mt_next_rel_upd_even: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i (padded_hash_fun #hsz f v (S.index mt (2 * i + 1))))) let mt_next_rel_upd_even #hsz #f n mt nmt i v = () #push-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val mt_next_rel_upd_even_pad: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash #hsz -> Lemma (requires (mt_next_rel #_ #f n mt nmt) /\ (S.index mt (2 * i + 1) == HPad)) (ensures (mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i v))) let mt_next_rel_upd_even_pad #hsz #f n mt nmt i v = () #pop-options val mt_next_rel_upd_odd: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i + 1) v) (S.upd nmt i (padded_hash_fun #_ f (S.index mt (2 * i)) v))) let mt_next_rel_upd_odd #hsz #f n mt nmt i v = () // fournet: just [root]? val mt_get_root: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> GTot (padded_hash #hsz) let rec mt_get_root #hsz #f #n mt = if n = 0 then mt.[0] else mt_get_root #_ #f (mt_next_lv #_ #f mt) #push-options "--initial_fuel 2 --max_fuel 2" val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt))) let rec mt_get_root_step #hsz #f #n mt = if n = 1 then () else begin mt_get_root_step #_ #f (mt_next_lv #_ #f mt); mt_next_lv_mt_left #_ #f mt; mt_next_lv_mt_right #_ #f mt end #pop-options type path #hsz n = S.lseq (padded_hash #hsz) n /// We first specify full paths, including padding. val mt_get_path: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> i:nat{i < pow2 n} -> GTot (path #hsz n) let rec mt_get_path #hsz #f #n t i = if n = 0 then S.empty else S.cons (if i % 2 = 0 then t.[i + 1] else t.[i - 1]) (mt_get_path #_ #f (mt_next_lv #_ #f t) (i / 2)) val mt_verify_: #hsz:pos -> #f:hash_fun_t #hsz ->#n:nat -> p:path #hsz n -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> GTot (padded_hash #hsz) let rec mt_verify_ #hsz #f #n p idx h = if n = 0 then h else mt_verify_ #_ #f #(n-1) (S.tail p) (idx / 2) (if idx % 2 = 0 then padded_hash_fun #_ f h (S.head p) else padded_hash_fun #_ f (S.head p) h) val mt_verify: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> p:(path #hsz n) -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> padded_hash #hsz -> GTot prop let mt_verify #hsz #f #n p idx h rt = rt == mt_verify_ #_ #f p idx h /// Correctness: the root of a tree is correctly recomputed from any of its paths val hs_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> hs:hashes{S.length hs = 2 * n} -> idx:nat{idx < 2 * n} -> Lemma ((hs_next_lv #_ #f #n hs).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f hs.[idx] hs.[idx + 1] else padded_hash_fun #_ f hs.[idx - 1] hs.[idx]))
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hs_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> hs:hashes{S.length hs = 2 * n} -> idx:nat{idx < 2 * n} -> Lemma ((hs_next_lv #_ #f #n hs).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f hs.[idx] hs.[idx + 1] else padded_hash_fun #_ f hs.[idx - 1] hs.[idx]))
[ "recursion" ]
MerkleTree.Spec.hs_next_lv_get
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
hs: MerkleTree.Spec.hashes{FStar.Seq.Base.length hs = 2 * n} -> idx: Prims.nat{idx < 2 * n} -> FStar.Pervasives.Lemma (ensures (MerkleTree.Spec.hs_next_lv hs).[ idx / 2 ] == (match idx % 2 = 0 with | true -> MerkleTree.Spec.padded_hash_fun f hs.[ idx ] hs.[ idx + 1 ] | _ -> MerkleTree.Spec.padded_hash_fun f hs.[ idx - 1 ] hs.[ idx ]))
{ "end_col": 73, "end_line": 288, "start_col": 2, "start_line": 287 }
Prims.Tot
val rpmt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #_ #f (n-1) (if i <= pow2 (n-1) then 0 else i - pow2 (n-1))
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 rpmt_right #hsz #f #n #i mt = if i <= pow2 (n-1) then pad_hashes_slice #_ #f (S.slice mt i (S.length mt)) (pow2 (n-1) - i) (pow2 n - i) else raw_hashes_slice #_ #f (S.slice mt 0 i) (pow2 (n-1)) i; mt_right mt
val rpmt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #_ #f (n-1) (if i <= pow2 (n-1) then 0 else i - pow2 (n-1)) let rpmt_right #hsz #f #n #i mt =
false
null
false
if i <= pow2 (n - 1) then pad_hashes_slice #_ #f (S.slice mt i (S.length mt)) (pow2 (n - 1) - i) (pow2 n - i) else raw_hashes_slice #_ #f (S.slice mt 0 i) (pow2 (n - 1)) i; mt_right mt
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "total" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.pow2", "MerkleTree.Spec.rpmt", "MerkleTree.Spec.mt_right", "Prims.unit", "Prims.op_Subtraction", "MerkleTree.Spec.pad_hashes_slice", "FStar.Seq.Base.slice", "MerkleTree.Spec.padded_hash", "FStar.Seq.Base.length", "Prims.bool", "MerkleTree.Spec.raw_hashes_slice" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end val mt_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> GTot (merkle_tree #hsz (n-1)) let mt_next_lv #_ #f #n mt = hs_next_lv #_ #f #(pow2 (n-1)) mt val mt_next_lv_mt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_left mt)) (mt_left (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_left #hsz #f #n mt = hs_next_lv_slice #_ #f #(pow2 (n-1)) mt 0 (pow2 (n-2)) val mt_next_lv_mt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_right mt)) (mt_right (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_right #hsz #f #n mt = hs_next_lv_slice #hsz #f #(pow2 (n-1)) mt (pow2 (n-2)) (pow2 (n-1)) val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2))) let hs_next_lv_equiv #hsz #f j n hs1 hs2 = forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i:nat{i < j / 2}). hs1'.[i] == padded_hash_fun #hsz f hs1.[2 * i] hs1.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs2'.[i] == padded_hash_fun #hsz f hs2.[2 * i] hs2.[2 * i + 1]); assert (forall (i:nat{i < j}). (S.slice hs1 0 j).[i] == (S.slice hs2 0 j).[i]); assert (forall (i:nat{i < j}). hs1.[i] == hs2.[i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i] == hs2.[2 * i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i + 1] == hs2.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs1'.[i] == hs2'.[i]) val mt_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= pow2 n} -> mt1:merkle_tree #hsz n -> mt2:merkle_tree #hsz n -> Lemma (requires S.equal (S.slice mt1 0 j) (S.slice mt2 0 j)) (ensures S.equal (S.slice (mt_next_lv #_ #f #_ mt1) 0 (j / 2)) (S.slice (mt_next_lv #_ #f #_ mt2) 0 (j / 2))) let mt_next_lv_equiv #hsz #f j n mt1 mt2 = hs_next_lv_equiv #_ #f j (pow2 (n-1)) mt1 mt2 val hs_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> nhs:hashes #hsz {S.length nhs = n} -> GTot Type0 let hs_next_rel #hsz #f n hs nhs = forall (i:nat{i < n}). S.index nhs i == padded_hash_fun #hsz f (S.index hs (2 * i)) (S.index hs (2 * i + 1)) val mt_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> GTot Type0 let mt_next_rel #hsz #f n mt nmt = hs_next_rel #hsz #f (pow2 (n-1)) mt nmt val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs)) let rec hs_next_rel_next_lv #hsz #f n hs nhs = if n = 0 then () else hs_next_rel_next_lv #_ #f (n - 1) (S.slice hs 2 (S.length hs)) (S.slice nhs 1 (S.length nhs)) val mt_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures S.equal nmt (mt_next_lv #_ #f mt)) let mt_next_rel_next_lv #hsz #f n mt nmt = hs_next_rel_next_lv #_ #f (pow2 (n-1)) mt nmt val mt_next_rel_upd_even: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i (padded_hash_fun #hsz f v (S.index mt (2 * i + 1))))) let mt_next_rel_upd_even #hsz #f n mt nmt i v = () #push-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val mt_next_rel_upd_even_pad: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash #hsz -> Lemma (requires (mt_next_rel #_ #f n mt nmt) /\ (S.index mt (2 * i + 1) == HPad)) (ensures (mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i v))) let mt_next_rel_upd_even_pad #hsz #f n mt nmt i v = () #pop-options val mt_next_rel_upd_odd: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i + 1) v) (S.upd nmt i (padded_hash_fun #_ f (S.index mt (2 * i)) v))) let mt_next_rel_upd_odd #hsz #f n mt nmt i v = () // fournet: just [root]? val mt_get_root: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> GTot (padded_hash #hsz) let rec mt_get_root #hsz #f #n mt = if n = 0 then mt.[0] else mt_get_root #_ #f (mt_next_lv #_ #f mt) #push-options "--initial_fuel 2 --max_fuel 2" val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt))) let rec mt_get_root_step #hsz #f #n mt = if n = 1 then () else begin mt_get_root_step #_ #f (mt_next_lv #_ #f mt); mt_next_lv_mt_left #_ #f mt; mt_next_lv_mt_right #_ #f mt end #pop-options type path #hsz n = S.lseq (padded_hash #hsz) n /// We first specify full paths, including padding. val mt_get_path: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> i:nat{i < pow2 n} -> GTot (path #hsz n) let rec mt_get_path #hsz #f #n t i = if n = 0 then S.empty else S.cons (if i % 2 = 0 then t.[i + 1] else t.[i - 1]) (mt_get_path #_ #f (mt_next_lv #_ #f t) (i / 2)) val mt_verify_: #hsz:pos -> #f:hash_fun_t #hsz ->#n:nat -> p:path #hsz n -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> GTot (padded_hash #hsz) let rec mt_verify_ #hsz #f #n p idx h = if n = 0 then h else mt_verify_ #_ #f #(n-1) (S.tail p) (idx / 2) (if idx % 2 = 0 then padded_hash_fun #_ f h (S.head p) else padded_hash_fun #_ f (S.head p) h) val mt_verify: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> p:(path #hsz n) -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> padded_hash #hsz -> GTot prop let mt_verify #hsz #f #n p idx h rt = rt == mt_verify_ #_ #f p idx h /// Correctness: the root of a tree is correctly recomputed from any of its paths val hs_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> hs:hashes{S.length hs = 2 * n} -> idx:nat{idx < 2 * n} -> Lemma ((hs_next_lv #_ #f #n hs).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f hs.[idx] hs.[idx + 1] else padded_hash_fun #_ f hs.[idx - 1] hs.[idx])) let rec hs_next_lv_get #hsz #f #n hs idx = if idx < 2 then () else hs_next_lv_get #_ #f #(n-1) (S.slice hs 2 (S.length hs)) (idx - 2) val mt_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> Lemma ( (mt_next_lv #_ #f mt).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f mt.[idx] mt.[idx + 1] else padded_hash_fun #_ f mt.[idx - 1] mt.[idx])) let mt_next_lv_get #hsz #f #n mt idx = hs_next_lv_get #_ #f #(pow2 (n-1)) mt idx val mt_get_path_ok_: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> t:merkle_tree #hsz n -> i:nat{i < pow2 n} -> Lemma (mt_verify_ #_ #f (mt_get_path #_ #f t i) i (mt_get t i) == mt_get_root #_ #f t) let rec mt_get_path_ok_ #hsz #f #n mt idx = if n = 0 then () else begin assert (S.head (mt_get_path #_ #f mt idx) == (if idx % 2 = 0 then mt.[idx + 1] else mt.[idx - 1])); assert (S.equal (S.tail (mt_get_path #_ #f mt idx)) (mt_get_path #_ #f (mt_next_lv #_ #f mt) (idx / 2))); mt_get_path_ok_ #_ #f (mt_next_lv #_ #f mt) (idx / 2); mt_next_lv_get #_ #f mt idx end /// Security: we reduce tree collisions to collisions on the hash /// compression function. Such collisions yield collisions on the SHA2 /// standard (by adding the same length and padding to the /// accumulators). /// /// One complication addressed in the proof is the handling of /// implicit padding. /// All hashes in a sequence are raw hashes, not padding val raw_hashes: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes #hsz -> Tot Type0 (decreases (S.length hs)) let rec raw_hashes #hsz #f hs = if S.length hs = 0 then True else (HRaw? (S.head hs) /\ raw_hashes #_ #f (S.tail hs)) val raw_hashes_raws: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes{raw_hashes #hsz #f hs} -> Tot (S.seq (hash #hsz)) (decreases (S.length hs)) let rec raw_hashes_raws #hsz #f hs = if S.length hs = 0 then S.empty else S.cons (HRaw?.hr (S.head hs)) (raw_hashes_raws #_ #f (S.tail hs)) val raw_hashes_index: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat{i < S.length hs} -> Lemma (requires raw_hashes #_ #f hs) (ensures HRaw? #hsz hs.[i]) (decreases i) let rec raw_hashes_index #hsz #f hs i = if i = 0 then () else raw_hashes_index #_ #f (S.tail hs) (i - 1) val raw_hashes_slice: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat -> j:nat{i <= j && j <= S.length hs} -> Lemma (requires raw_hashes #_ #f hs) (ensures raw_hashes #_ #f (S.slice hs i j)) (decreases (j - i)) let rec raw_hashes_slice #hsz #f hs i j = if i = j then () else ( raw_hashes_index #_ #f hs i; raw_hashes_slice #_ #f hs (i + 1) j) /// All hashes in a sequence are just padding val pad_hashes: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes #hsz -> Type0 let pad_hashes #hsz #f hs = S.equal hs (S.create (S.length hs) HPad) val pad_hashes_slice: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat -> j:nat{i <= j && j <= S.length hs} -> Lemma (requires pad_hashes #_ #f hs) (ensures pad_hashes #_ #f (S.slice hs i j)) (decreases (j - i)) let rec pad_hashes_slice #hsz #f hs i j = if i = j then () else pad_hashes_slice #_ #f hs (i + 1) j /// Right-padded Merkle tree, a tree refinement let rpmt (#hsz:pos) (#f:hash_fun_t) (n:nat) (i:nat{i <= pow2 n}) = mt:merkle_tree #hsz n { raw_hashes #_ #f (S.slice mt 0 i) /\ pad_hashes #_ #f (S.slice mt i (S.length mt)) } val rpmt_raws: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #hsz #f n i -> S.seq (hash #hsz) let rpmt_raws #hsz #f #n #i mt = raw_hashes_raws #_ #f (S.slice mt 0 i) val rpmt_i_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:rpmt #hsz #f n 0 -> Lemma (S.equal mt (S.create (pow2 n) (HPad #hsz))) let rpmt_i_0 #hsz #f #n mt = () val rpmt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #hsz #f (n-1) (if i <= pow2 (n-1) then i else pow2 (n-1)) let rpmt_left #hsz #f #n #i mt = if i <= pow2 (n-1) then pad_hashes_slice #_ #f (S.slice mt i (S.length mt)) 0 (pow2 (n-1) - i) else raw_hashes_slice #_ #f (S.slice mt 0 i) 0 (pow2 (n-1)); mt_left mt #push-options "--z3rlimit 40" val rpmt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #_ #f (n-1) (if i <= pow2 (n-1) then 0 else i - pow2 (n-1))
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rpmt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #_ #f (n-1) (if i <= pow2 (n-1) then 0 else i - pow2 (n-1))
[]
MerkleTree.Spec.rpmt_right
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
mt: MerkleTree.Spec.rpmt n i -> MerkleTree.Spec.rpmt (n - 1) (match i <= Prims.pow2 (n - 1) with | true -> 0 | _ -> i - Prims.pow2 (n - 1))
{ "end_col": 13, "end_line": 410, "start_col": 2, "start_line": 407 }
Prims.GTot
val extract: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt_collide #_ #f n i -> GTot hash2_raw_collide
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree", "short_module": null }, { "abbrev": 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 extract #hsz #f #n #i (Collision t1 t2) = assert(n = 0 ==> S.equal t1 t2); // excludes n = 0 mt_left_right t1; mt_left_right t2; mt_get_root_step #_ #f t1; mt_get_root_step #_ #f t2; rpmt_get_root_pad t1; assert(i <> 0); let l1 = rpmt_left t1 in let l2 = rpmt_left t2 in let r1 = rpmt_right t1 in let r2 = rpmt_right t2 in if i <= pow2 (n-1) then ( rpmt_get_root_pad r1; rpmt_get_root_pad r2; rpmt_i_0 #_ #f r1; rpmt_i_0 #_ #f r2; extract (Collision l1 l2)) else ( rpmt_get_root_raw l1; rpmt_get_root_raw l2; rpmt_get_root_raw r1; rpmt_get_root_raw r2; let HRaw lh1 = mt_get_root #_ #f l1 in let HRaw lh2 = mt_get_root #_ #f l2 in let HRaw rh1 = mt_get_root #_ #f r1 in let HRaw rh2 = mt_get_root #_ #f r2 in if StrongExcludedMiddle.strong_excluded_middle (lh1 =!= lh2) || StrongExcludedMiddle.strong_excluded_middle (rh1 =!= rh2) then Collision2 #_ #f lh1 rh1 lh2 rh2 else if StrongExcludedMiddle.strong_excluded_middle (l1 == l2) then extract (Collision r1 r2) else extract (Collision l1 l2))
val extract: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt_collide #_ #f n i -> GTot hash2_raw_collide let rec extract #hsz #f #n #i (Collision t1 t2) =
false
null
false
assert (n = 0 ==> S.equal t1 t2); mt_left_right t1; mt_left_right t2; mt_get_root_step #_ #f t1; mt_get_root_step #_ #f t2; rpmt_get_root_pad t1; assert (i <> 0); let l1 = rpmt_left t1 in let l2 = rpmt_left t2 in let r1 = rpmt_right t1 in let r2 = rpmt_right t2 in if i <= pow2 (n - 1) then (rpmt_get_root_pad r1; rpmt_get_root_pad r2; rpmt_i_0 #_ #f r1; rpmt_i_0 #_ #f r2; extract (Collision l1 l2)) else (rpmt_get_root_raw l1; rpmt_get_root_raw l2; rpmt_get_root_raw r1; rpmt_get_root_raw r2; let HRaw lh1 = mt_get_root #_ #f l1 in let HRaw lh2 = mt_get_root #_ #f l2 in let HRaw rh1 = mt_get_root #_ #f r1 in let HRaw rh2 = mt_get_root #_ #f r2 in if StrongExcludedMiddle.strong_excluded_middle (lh1 =!= lh2) || StrongExcludedMiddle.strong_excluded_middle (rh1 =!= rh2) then Collision2 #_ #f lh1 rh1 lh2 rh2 else if StrongExcludedMiddle.strong_excluded_middle (l1 == l2) then extract (Collision r1 r2) else extract (Collision l1 l2))
{ "checked_file": "MerkleTree.Spec.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "FStar.StrongExcludedMiddle.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Spec.fst" }
[ "sometrivial" ]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.pow2", "MerkleTree.Spec.mt_collide", "MerkleTree.Spec.rpmt", "Prims.l_and", "Prims.l_not", "Prims.eq2", "MerkleTree.Spec.padded_hash", "MerkleTree.Spec.mt_get_root", "Prims.op_Subtraction", "MerkleTree.Spec.extract", "Prims.bool", "MerkleTree.Spec.Collision", "Prims.unit", "MerkleTree.Spec.rpmt_i_0", "MerkleTree.Spec.rpmt_get_root_pad", "MerkleTree.Spec.hash", "Prims.op_BarBar", "FStar.StrongExcludedMiddle.strong_excluded_middle", "MerkleTree.Spec.Collision2", "MerkleTree.Spec.hash2_raw_collide", "MerkleTree.Spec.rpmt_get_root_raw", "MerkleTree.Spec.rpmt_right", "MerkleTree.Spec.rpmt_left", "Prims._assert", "Prims.op_disEquality", "Prims.int", "MerkleTree.Spec.mt_get_root_step", "MerkleTree.Spec.mt_left_right", "Prims.l_imp", "Prims.op_Equality", "FStar.Seq.Base.equal" ]
[]
module MerkleTree.Spec open FStar.Classical open FStar.Mul open FStar.Seq module S = FStar.Seq #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 10" // For SHA2_256, this is is a sequence of 32 bytes // These are secret bytes, hence not an eqtype type hash (#hsz:pos) = b:Spec.Hash.Definitions.bytes { Seq.length b = hsz } type hash_fun_t (#hsz:pos) = hash #hsz -> hash #hsz -> GTot (hash #hsz) val sha256_compress: hash_fun_t #32 let sha256_compress src1 src2 = let sz = Spec.Hash.Definitions.SHA2_256 in let hash_alg = Spec.Hash.Definitions.SHA2_256 in let acc = Spec.Agile.Hash.init hash_alg in let acc = Spec.Agile.Hash.update hash_alg acc (S.append src1 src2) in Spec.Agile.Hash.finish hash_alg acc () /// For simplicity, we will specify the root for a sequence of [i] /// tags where [i <= 2^n] as the root of a full binary tree with [2^n] /// leaves obtained by padding the sequence with dummies. This /// requires extending the definitions of hashes and hash functions. Our /// extended definition of hash justifies skipping any concrete /// computation on dummies. noeq type padded_hash #hsz = | HRaw: hr:hash #hsz -> padded_hash #hsz | HPad // right padding to make the size of a Merkle tree a power of 2 val padded_hash_fun: (#hsz:pos) -> (f:hash_fun_t #hsz) -> (lh:padded_hash #hsz) -> (rh:padded_hash #hsz) -> GTot (padded_hash #hsz) let padded_hash_fun #hsz f lh rh = allow_inversion (padded_hash #hsz); match lh, rh with | HPad , _ -> HPad | _ , HPad -> lh | HRaw lhr, HRaw rhr -> HRaw (f lhr rhr) noextract val hashes (#hsz:pos): Type0 let hashes #hsz = S.seq (padded_hash #hsz) type merkle_tree (#hsz:pos) n = hs:hashes #hsz {S.length hs = pow2 n} val mt_get: #hsz:pos -> #n:nat -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> GTot (padded_hash #hsz) let mt_get #_ #_ mt idx = S.index mt idx unfold let op_String_Access (#hsz:pos) = S.index #(padded_hash #hsz) #push-options "--max_fuel 1" val mt_left: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_left #_ #n mt = S.slice mt 0 (pow2 (n-1)) val mt_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> merkle_tree #hsz (n-1) let mt_right #_ #n mt = S.slice mt (pow2 (n-1)) (pow2 n) val mt_left_right: #hsz:pos -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (S.equal mt (mt_left mt @| mt_right mt)) let mt_left_right #_ #_ mt = () val hs_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> GTot (nhs:hashes #hsz {S.length nhs = n}) let rec hs_next_lv #hsz #f #n hs = if n = 0 then S.empty else S.cons (padded_hash_fun #hsz f hs.[0] hs.[1]) (hs_next_lv #hsz #f #(n-1) (S.slice hs 2 (S.length hs))) val hs_next_lv_index: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat{i < n} -> Lemma ((hs_next_lv #hsz #f #n hs).[i] == padded_hash_fun #hsz f hs.[2 * i] hs.[2 * i + 1]) let rec hs_next_lv_index #hsz #f #n hs i = if n = 0 || i = 0 then () else hs_next_lv_index #hsz #f #(n - 1) (S.slice hs 2 (S.length hs)) (i - 1) val hs_next_lv_slice: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> hs:hashes{S.length hs = 2 * n} -> i:nat -> j:nat{i <= j && j <= n} -> Lemma (requires True) (ensures S.equal (hs_next_lv #hsz #f #(j - i) (S.slice hs (2 * i) (2 * j))) (S.slice (hs_next_lv #hsz #f #n hs) i j)) (decreases (j - i)) let rec hs_next_lv_slice #hsz #f #n hs i j = if i = j then () else begin let x = S.slice hs (2 * i) (2 * j) in assert (S.equal (hs_next_lv #hsz #f #(j - i) x) (S.cons (padded_hash_fun #hsz f x.[0] x.[1]) (hs_next_lv #hsz #f #(j - i - 1) (S.slice x 2 (S.length x))))); hs_next_lv_slice #hsz #f #n hs (i + 1) j; hs_next_lv_index #hsz #f #n hs i end val mt_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> GTot (merkle_tree #hsz (n-1)) let mt_next_lv #_ #f #n mt = hs_next_lv #_ #f #(pow2 (n-1)) mt val mt_next_lv_mt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_left mt)) (mt_left (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_left #hsz #f #n mt = hs_next_lv_slice #_ #f #(pow2 (n-1)) mt 0 (pow2 (n-2)) val mt_next_lv_mt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat{1 < n} -> mt:merkle_tree #hsz n -> Lemma (S.equal (mt_next_lv #_ #f #_ (mt_right mt)) (mt_right (mt_next_lv #_ #f #_ mt))) let mt_next_lv_mt_right #hsz #f #n mt = hs_next_lv_slice #hsz #f #(pow2 (n-1)) mt (pow2 (n-2)) (pow2 (n-1)) val hs_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= 2 * n} -> hs1:hashes{S.length hs1 = 2 * n} -> hs2:hashes{S.length hs2 = 2 * n} -> Lemma (requires S.equal (S.slice hs1 0 j) (S.slice hs2 0 j)) (ensures S.equal (S.slice (hs_next_lv #hsz #f #n hs1) 0 (j / 2)) (S.slice (hs_next_lv #hsz #f #n hs2) 0 (j / 2))) let hs_next_lv_equiv #hsz #f j n hs1 hs2 = forall_intro (hs_next_lv_index #_ #f #n hs1); forall_intro (hs_next_lv_index #_ #f #n hs2); let hs1' = hs_next_lv #_ #f #n hs1 in let hs2' = hs_next_lv #_ #f #n hs2 in assert (forall (i:nat{i < j / 2}). hs1'.[i] == padded_hash_fun #hsz f hs1.[2 * i] hs1.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs2'.[i] == padded_hash_fun #hsz f hs2.[2 * i] hs2.[2 * i + 1]); assert (forall (i:nat{i < j}). (S.slice hs1 0 j).[i] == (S.slice hs2 0 j).[i]); assert (forall (i:nat{i < j}). hs1.[i] == hs2.[i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i] == hs2.[2 * i]); assert (forall (i:nat{i < j / 2}). hs1.[2 * i + 1] == hs2.[2 * i + 1]); assert (forall (i:nat{i < j / 2}). hs1'.[i] == hs2'.[i]) val mt_next_lv_equiv: #hsz:pos -> #f:hash_fun_t #hsz -> j:nat -> n:pos{j <= pow2 n} -> mt1:merkle_tree #hsz n -> mt2:merkle_tree #hsz n -> Lemma (requires S.equal (S.slice mt1 0 j) (S.slice mt2 0 j)) (ensures S.equal (S.slice (mt_next_lv #_ #f #_ mt1) 0 (j / 2)) (S.slice (mt_next_lv #_ #f #_ mt2) 0 (j / 2))) let mt_next_lv_equiv #hsz #f j n mt1 mt2 = hs_next_lv_equiv #_ #f j (pow2 (n-1)) mt1 mt2 val hs_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes #hsz {S.length hs = 2 * n} -> nhs:hashes #hsz {S.length nhs = n} -> GTot Type0 let hs_next_rel #hsz #f n hs nhs = forall (i:nat{i < n}). S.index nhs i == padded_hash_fun #hsz f (S.index hs (2 * i)) (S.index hs (2 * i + 1)) val mt_next_rel: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> GTot Type0 let mt_next_rel #hsz #f n mt nmt = hs_next_rel #hsz #f (pow2 (n-1)) mt nmt val hs_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:nat -> hs:hashes{S.length hs = 2 * n} -> nhs:hashes{S.length nhs = n} -> Lemma (requires hs_next_rel #_ #f n hs nhs) (ensures S.equal nhs (hs_next_lv #_ #f #n hs)) let rec hs_next_rel_next_lv #hsz #f n hs nhs = if n = 0 then () else hs_next_rel_next_lv #_ #f (n - 1) (S.slice hs 2 (S.length hs)) (S.slice nhs 1 (S.length nhs)) val mt_next_rel_next_lv: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures S.equal nmt (mt_next_lv #_ #f mt)) let mt_next_rel_next_lv #hsz #f n mt nmt = hs_next_rel_next_lv #_ #f (pow2 (n-1)) mt nmt val mt_next_rel_upd_even: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i (padded_hash_fun #hsz f v (S.index mt (2 * i + 1))))) let mt_next_rel_upd_even #hsz #f n mt nmt i v = () #push-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" val mt_next_rel_upd_even_pad: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree #hsz (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash #hsz -> Lemma (requires (mt_next_rel #_ #f n mt nmt) /\ (S.index mt (2 * i + 1) == HPad)) (ensures (mt_next_rel #_ #f n (S.upd mt (2 * i) v) (S.upd nmt i v))) let mt_next_rel_upd_even_pad #hsz #f n mt nmt i v = () #pop-options val mt_next_rel_upd_odd: #hsz:pos -> #f:hash_fun_t #hsz -> n:pos -> mt:merkle_tree #hsz n -> nmt:merkle_tree (n - 1) -> i:nat{i < pow2 (n-1)} -> v:padded_hash -> Lemma (requires mt_next_rel #_ #f n mt nmt) (ensures mt_next_rel #_ #f n (S.upd mt (2 * i + 1) v) (S.upd nmt i (padded_hash_fun #_ f (S.index mt (2 * i)) v))) let mt_next_rel_upd_odd #hsz #f n mt nmt i v = () // fournet: just [root]? val mt_get_root: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> GTot (padded_hash #hsz) let rec mt_get_root #hsz #f #n mt = if n = 0 then mt.[0] else mt_get_root #_ #f (mt_next_lv #_ #f mt) #push-options "--initial_fuel 2 --max_fuel 2" val mt_get_root_step: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> Lemma (mt_get_root #_ #f mt == padded_hash_fun #_ f (mt_get_root #_ #f (mt_left mt)) (mt_get_root #_ #f (mt_right mt))) let rec mt_get_root_step #hsz #f #n mt = if n = 1 then () else begin mt_get_root_step #_ #f (mt_next_lv #_ #f mt); mt_next_lv_mt_left #_ #f mt; mt_next_lv_mt_right #_ #f mt end #pop-options type path #hsz n = S.lseq (padded_hash #hsz) n /// We first specify full paths, including padding. val mt_get_path: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> i:nat{i < pow2 n} -> GTot (path #hsz n) let rec mt_get_path #hsz #f #n t i = if n = 0 then S.empty else S.cons (if i % 2 = 0 then t.[i + 1] else t.[i - 1]) (mt_get_path #_ #f (mt_next_lv #_ #f t) (i / 2)) val mt_verify_: #hsz:pos -> #f:hash_fun_t #hsz ->#n:nat -> p:path #hsz n -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> GTot (padded_hash #hsz) let rec mt_verify_ #hsz #f #n p idx h = if n = 0 then h else mt_verify_ #_ #f #(n-1) (S.tail p) (idx / 2) (if idx % 2 = 0 then padded_hash_fun #_ f h (S.head p) else padded_hash_fun #_ f (S.head p) h) val mt_verify: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> p:(path #hsz n) -> idx:nat{idx < pow2 n} -> padded_hash #hsz -> padded_hash #hsz -> GTot prop let mt_verify #hsz #f #n p idx h rt = rt == mt_verify_ #_ #f p idx h /// Correctness: the root of a tree is correctly recomputed from any of its paths val hs_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> hs:hashes{S.length hs = 2 * n} -> idx:nat{idx < 2 * n} -> Lemma ((hs_next_lv #_ #f #n hs).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f hs.[idx] hs.[idx + 1] else padded_hash_fun #_ f hs.[idx - 1] hs.[idx])) let rec hs_next_lv_get #hsz #f #n hs idx = if idx < 2 then () else hs_next_lv_get #_ #f #(n-1) (S.slice hs 2 (S.length hs)) (idx - 2) val mt_next_lv_get: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> mt:merkle_tree #hsz n -> idx:nat{idx < pow2 n} -> Lemma ( (mt_next_lv #_ #f mt).[idx / 2] == (if idx % 2 = 0 then padded_hash_fun #_ f mt.[idx] mt.[idx + 1] else padded_hash_fun #_ f mt.[idx - 1] mt.[idx])) let mt_next_lv_get #hsz #f #n mt idx = hs_next_lv_get #_ #f #(pow2 (n-1)) mt idx val mt_get_path_ok_: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> t:merkle_tree #hsz n -> i:nat{i < pow2 n} -> Lemma (mt_verify_ #_ #f (mt_get_path #_ #f t i) i (mt_get t i) == mt_get_root #_ #f t) let rec mt_get_path_ok_ #hsz #f #n mt idx = if n = 0 then () else begin assert (S.head (mt_get_path #_ #f mt idx) == (if idx % 2 = 0 then mt.[idx + 1] else mt.[idx - 1])); assert (S.equal (S.tail (mt_get_path #_ #f mt idx)) (mt_get_path #_ #f (mt_next_lv #_ #f mt) (idx / 2))); mt_get_path_ok_ #_ #f (mt_next_lv #_ #f mt) (idx / 2); mt_next_lv_get #_ #f mt idx end /// Security: we reduce tree collisions to collisions on the hash /// compression function. Such collisions yield collisions on the SHA2 /// standard (by adding the same length and padding to the /// accumulators). /// /// One complication addressed in the proof is the handling of /// implicit padding. /// All hashes in a sequence are raw hashes, not padding val raw_hashes: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes #hsz -> Tot Type0 (decreases (S.length hs)) let rec raw_hashes #hsz #f hs = if S.length hs = 0 then True else (HRaw? (S.head hs) /\ raw_hashes #_ #f (S.tail hs)) val raw_hashes_raws: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes{raw_hashes #hsz #f hs} -> Tot (S.seq (hash #hsz)) (decreases (S.length hs)) let rec raw_hashes_raws #hsz #f hs = if S.length hs = 0 then S.empty else S.cons (HRaw?.hr (S.head hs)) (raw_hashes_raws #_ #f (S.tail hs)) val raw_hashes_index: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat{i < S.length hs} -> Lemma (requires raw_hashes #_ #f hs) (ensures HRaw? #hsz hs.[i]) (decreases i) let rec raw_hashes_index #hsz #f hs i = if i = 0 then () else raw_hashes_index #_ #f (S.tail hs) (i - 1) val raw_hashes_slice: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat -> j:nat{i <= j && j <= S.length hs} -> Lemma (requires raw_hashes #_ #f hs) (ensures raw_hashes #_ #f (S.slice hs i j)) (decreases (j - i)) let rec raw_hashes_slice #hsz #f hs i j = if i = j then () else ( raw_hashes_index #_ #f hs i; raw_hashes_slice #_ #f hs (i + 1) j) /// All hashes in a sequence are just padding val pad_hashes: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes #hsz -> Type0 let pad_hashes #hsz #f hs = S.equal hs (S.create (S.length hs) HPad) val pad_hashes_slice: #hsz:pos -> #f:hash_fun_t #hsz -> hs:hashes -> i:nat -> j:nat{i <= j && j <= S.length hs} -> Lemma (requires pad_hashes #_ #f hs) (ensures pad_hashes #_ #f (S.slice hs i j)) (decreases (j - i)) let rec pad_hashes_slice #hsz #f hs i j = if i = j then () else pad_hashes_slice #_ #f hs (i + 1) j /// Right-padded Merkle tree, a tree refinement let rpmt (#hsz:pos) (#f:hash_fun_t) (n:nat) (i:nat{i <= pow2 n}) = mt:merkle_tree #hsz n { raw_hashes #_ #f (S.slice mt 0 i) /\ pad_hashes #_ #f (S.slice mt i (S.length mt)) } val rpmt_raws: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #hsz #f n i -> S.seq (hash #hsz) let rpmt_raws #hsz #f #n #i mt = raw_hashes_raws #_ #f (S.slice mt 0 i) val rpmt_i_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:rpmt #hsz #f n 0 -> Lemma (S.equal mt (S.create (pow2 n) (HPad #hsz))) let rpmt_i_0 #hsz #f #n mt = () val rpmt_left: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #hsz #f (n-1) (if i <= pow2 (n-1) then i else pow2 (n-1)) let rpmt_left #hsz #f #n #i mt = if i <= pow2 (n-1) then pad_hashes_slice #_ #f (S.slice mt i (S.length mt)) 0 (pow2 (n-1) - i) else raw_hashes_slice #_ #f (S.slice mt 0 i) 0 (pow2 (n-1)); mt_left mt #push-options "--z3rlimit 40" val rpmt_right: #hsz:pos -> #f:hash_fun_t #hsz -> #n:pos -> #i:nat{i <= pow2 n} -> rpmt #hsz #f n i -> rpmt #_ #f (n-1) (if i <= pow2 (n-1) then 0 else i - pow2 (n-1)) let rpmt_right #hsz #f #n #i mt = if i <= pow2 (n-1) then pad_hashes_slice #_ #f (S.slice mt i (S.length mt)) (pow2 (n-1) - i) (pow2 n - i) else raw_hashes_slice #_ #f (S.slice mt 0 i) (pow2 (n-1)) i; mt_right mt /// Two right-padded Merkle trees collide when /// 1) they have the same height (`n`) and number of raw hashes (`i`), /// 2) their contents differ, and /// 3) their roots are same. // fournet: we may want to work towards removing 1) using a hash prefix noeq type mt_collide (#hsz:pos) (#f:hash_fun_t #hsz) (n:nat) (i:nat{i <= pow2 n}) = | Collision: mt1:rpmt #_ #f n i -> mt2:rpmt #_ #f n i { mt1 =!= mt2 /\ mt_get_root #_ #f #_ mt1 == mt_get_root #_ #f #_ mt2 } -> mt_collide #_ #f n i noeq type hash2_raw_collide = | Collision2: #hsz:pos -> #f:hash_fun_t #hsz -> lh1:hash -> rh1:hash -> lh2:hash -> rh2:hash { (lh1 =!= lh2 \/ rh1 =!= rh2) /\ f lh1 rh1 == f lh2 rh2 } -> hash2_raw_collide /// Auxiliary lemmas for the proof val rpmt_pad_hashes_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #_ #f n i -> Lemma (i = 0 <==> pad_hashes #_ #f mt ) let rpmt_pad_hashes_0 #_ #_ #n #i mt = () val rpmt_pad_hashes_index_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #_ #f n i -> Lemma (pad_hashes #_ #f mt <==> HPad? mt.[0]) let rpmt_pad_hashes_index_0 #_ #_ #n #i mt = () val mt_get_root_pad_index_0: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> mt:merkle_tree #hsz n -> Lemma (HPad? mt.[0] <==> HPad? (mt_get_root #_ #f mt)) let rec mt_get_root_pad_index_0 #hsz #f #n (mt:merkle_tree #hsz n) = if n = 0 then () else let mt:merkle_tree #hsz (n-1) = mt_next_lv #_ #f #n mt in mt_get_root_pad_index_0 #_ #f #(n-1) mt #pop-options val rpmt_get_root_pad_hashes: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #_ #f n i -> Lemma (pad_hashes #_ #f mt <==> HPad? (mt_get_root #_ #f mt)) let rpmt_get_root_pad_hashes #_ #f #n #i mt = rpmt_pad_hashes_index_0 #_ #f mt; mt_get_root_pad_index_0 #_ #f mt val rpmt_get_root_pad: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #_ #f n i -> Lemma (i = 0 <==> HPad? (mt_get_root #_ #f mt)) let rpmt_get_root_pad #_ #f #n #i mt = rpmt_get_root_pad_hashes #_ #f mt; rpmt_pad_hashes_0 #_ #f mt val rpmt_get_root_raw: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt:rpmt #_ #f n i -> Lemma (i > 0 <==> HRaw? (mt_get_root #_ #f mt)) let rpmt_get_root_raw #hsz #f #n #i mt = allow_inversion (padded_hash #hsz); rpmt_get_root_pad #_ #f mt #push-options "--z3rlimit 100" val extract: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt_collide #_ #f n i -> GTot hash2_raw_collide
false
false
MerkleTree.Spec.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val extract: #hsz:pos -> #f:hash_fun_t #hsz -> #n:nat -> #i:nat{i <= pow2 n} -> mt_collide #_ #f n i -> GTot hash2_raw_collide
[ "recursion" ]
MerkleTree.Spec.extract
{ "file_name": "src/MerkleTree.Spec.fst", "git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
_: MerkleTree.Spec.mt_collide n i -> Prims.GTot MerkleTree.Spec.hash2_raw_collide
{ "end_col": 37, "end_line": 516, "start_col": 2, "start_line": 489 }
FStar.Tactics.Effect.Tac
[ { "abbrev": false, "full_module": "Steel.C", "short_module": null }, { "abbrev": false, "full_module": "Steel.C", "short_module": null }, { "abbrev": 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 solve_nat_t_of_nat () = FStar.Tactics.norm norm_typenat; FStar.Tactics.trefl ()
let solve_nat_t_of_nat () =
true
null
false
FStar.Tactics.norm norm_typenat; FStar.Tactics.trefl ()
{ "checked_file": "Steel.C.Typenat.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.C.Typenat.fsti" }
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.trefl", "FStar.Tactics.V1.Builtins.norm", "Steel.C.Typenat.norm_typenat" ]
[]
module Steel.C.Typenat (** Suppose [array (n : nat) (t : Type)] represents the type of array values. Then, when extracting values of type [ref (array n t)], the length n is lost. To make sure this information sticks around, this module provides an encoding of natural numbers as types. *) val z: Type0 val s: Type0 -> Type0 let rec nat_t_of_nat (n: nat): Type0 = match n with | 0 -> z | n -> s (nat_t_of_nat (n - 1)) unfold let norm_typenat = [ delta_only [ `%nat_t_of_nat; ]; iota; zeta; primops; ]
false
false
Steel.C.Typenat.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val solve_nat_t_of_nat : _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
[]
Steel.C.Typenat.solve_nat_t_of_nat
{ "file_name": "lib/steel/c/Steel.C.Typenat.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 24, "end_line": 27, "start_col": 2, "start_line": 26 }
Prims.Tot
[ { "abbrev": false, "full_module": "Steel.C", "short_module": null }, { "abbrev": false, "full_module": "Steel.C", "short_module": null }, { "abbrev": 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 norm_typenat = [ delta_only [ `%nat_t_of_nat; ]; iota; zeta; primops; ]
let norm_typenat =
false
null
false
[delta_only [`%nat_t_of_nat]; iota; zeta; primops]
{ "checked_file": "Steel.C.Typenat.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.C.Typenat.fsti" }
[ "total" ]
[ "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops" ]
[]
module Steel.C.Typenat (** Suppose [array (n : nat) (t : Type)] represents the type of array values. Then, when extracting values of type [ref (array n t)], the length n is lost. To make sure this information sticks around, this module provides an encoding of natural numbers as types. *) val z: Type0 val s: Type0 -> Type0 let rec nat_t_of_nat (n: nat): Type0 = match n with | 0 -> z | n -> s (nat_t_of_nat (n - 1)) unfold
false
true
Steel.C.Typenat.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val norm_typenat : Prims.list FStar.Pervasives.norm_step
[]
Steel.C.Typenat.norm_typenat
{ "file_name": "lib/steel/c/Steel.C.Typenat.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
Prims.list FStar.Pervasives.norm_step
{ "end_col": 3, "end_line": 23, "start_col": 2, "start_line": 18 }
Prims.Tot
val nat_t_of_nat (n: nat) : Type0
[ { "abbrev": false, "full_module": "Steel.C", "short_module": null }, { "abbrev": false, "full_module": "Steel.C", "short_module": null }, { "abbrev": 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 nat_t_of_nat (n: nat): Type0 = match n with | 0 -> z | n -> s (nat_t_of_nat (n - 1))
val nat_t_of_nat (n: nat) : Type0 let rec nat_t_of_nat (n: nat) : Type0 =
false
null
false
match n with | 0 -> z | n -> s (nat_t_of_nat (n - 1))
{ "checked_file": "Steel.C.Typenat.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.C.Typenat.fsti" }
[ "total" ]
[ "Prims.nat", "Steel.C.Typenat.z", "Prims.int", "Steel.C.Typenat.s", "Steel.C.Typenat.nat_t_of_nat", "Prims.op_Subtraction" ]
[]
module Steel.C.Typenat (** Suppose [array (n : nat) (t : Type)] represents the type of array values. Then, when extracting values of type [ref (array n t)], the length n is lost. To make sure this information sticks around, this module provides an encoding of natural numbers as types. *) val z: Type0 val s: Type0 -> Type0
false
true
Steel.C.Typenat.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nat_t_of_nat (n: nat) : Type0
[ "recursion" ]
Steel.C.Typenat.nat_t_of_nat
{ "file_name": "lib/steel/c/Steel.C.Typenat.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.nat -> Type0
{ "end_col": 33, "end_line": 14, "start_col": 2, "start_line": 12 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint64 = UInt64.t
let uint64 =
false
null
false
UInt64.t
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "FStar.UInt64.t" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil
false
true
Vale.Inline.X64.Fswap_inline.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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint64 : Prims.eqtype
[]
Vale.Inline.X64.Fswap_inline.uint64
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.eqtype
{ "end_col": 21, "end_line": 25, "start_col": 13, "start_line": 25 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let b64 = buf_t TUInt64 TUInt64
let b64 =
false
null
false
buf_t TUInt64 TUInt64
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Interop.Base.buf_t", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x
false
true
Vale.Inline.X64.Fswap_inline.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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val b64 : Type0
[]
Vale.Inline.X64.Fswap_inline.b64
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 31, "end_line": 32, "start_col": 10, "start_line": 32 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap_xmms_modified = fun _ -> false
let cswap_xmms_modified =
false
null
false
fun _ -> false
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Prims.bool" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false
false
false
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap_xmms_modified : _: _ -> Prims.bool
[]
Vale.Inline.X64.Fswap_inline.cswap_xmms_modified
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: _ -> Prims.bool
{ "end_col": 40, "end_line": 75, "start_col": 26, "start_line": 75 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
let t64_no_mod =
false
null
false
TD_Buffer TUInt64 TUInt64 ({ modified = false; strict_disjointness = false; taint = MS.Secret })
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Interop.Base.TD_Buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Vale.Interop.Base.Mkbuffer_qualifiers", "Vale.Arch.HeapTypes_s.Secret" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
false
true
Vale.Inline.X64.Fswap_inline.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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val t64_no_mod : Vale.Interop.Base.td
[]
Vale.Inline.X64.Fswap_inline.t64_no_mod
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Interop.Base.td
{ "end_col": 105, "end_line": 36, "start_col": 17, "start_line": 36 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let tuint64 = TD_Base TUInt64
let tuint64 =
false
null
false
TD_Base TUInt64
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
false
true
Vale.Inline.X64.Fswap_inline.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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val tuint64 : Vale.Interop.Base.td
[]
Vale.Inline.X64.Fswap_inline.tuint64
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Interop.Base.td
{ "end_col": 29, "end_line": 38, "start_col": 14, "start_line": 38 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
let t64_mod =
false
null
false
TD_Buffer TUInt64 TUInt64 default_bq
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Interop.Base.TD_Buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Vale.Interop.Base.default_bq" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64
false
true
Vale.Inline.X64.Fswap_inline.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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val t64_mod : Vale.Interop.Base.td
[]
Vale.Inline.X64.Fswap_inline.t64_mod
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Interop.Base.td
{ "end_col": 50, "end_line": 34, "start_col": 14, "start_line": 34 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let code_cswap = FU.va_code_Cswap2 ()
let code_cswap =
false
null
false
FU.va_code_Cswap2 ()
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Curve25519.X64.FastUtil.va_code_Cswap2" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma'
false
true
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val code_cswap : Vale.X64.Decls.va_code
[]
Vale.Inline.X64.Fswap_inline.code_cswap
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.X64.Decls.va_code
{ "end_col": 37, "end_line": 108, "start_col": 17, "start_line": 108 }
Prims.Tot
val of_reg (r: MS.reg_64) : option (IX64.reg_nat 3)
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None
val of_reg (r: MS.reg_64) : option (IX64.reg_nat 3) let of_reg (r: MS.reg_64) : option (IX64.reg_nat 3) =
false
null
false
match r with | 5 -> Some 0 | 4 -> Some 1 | 3 -> Some 2 | _ -> None
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.reg_64", "FStar.Pervasives.Native.Some", "Vale.Interop.X64.reg_nat", "Prims.int", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 ()
false
false
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val of_reg (r: MS.reg_64) : option (IX64.reg_nat 3)
[]
Vale.Inline.X64.Fswap_inline.of_reg
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r: Vale.X64.Machine_s.reg_64 -> FStar.Pervasives.Native.option (Vale.Interop.X64.reg_nat 3)
{ "end_col": 13, "end_line": 114, "start_col": 53, "start_line": 110 }
Prims.Tot
val cswap_names (n: nat) : string
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap_names (n:nat) : string = match n with | 0 -> "bit" | 1 -> "p1" | 2 -> "p2" | _ -> ""
val cswap_names (n: nat) : string let cswap_names (n: nat) : string =
false
null
false
match n with | 0 -> "bit" | 1 -> "p1" | 2 -> "p2" | _ -> ""
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Prims.nat", "Prims.int", "Prims.string" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the cswap wrapper *) [@__reduce__] let lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) (* And here's the cswap wrapper itself *) let lowstar_cswap : lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) let lowstar_cswap_normal_t : normal lowstar_cswap_t = as_normal_t #lowstar_cswap_t lowstar_cswap open Vale.AsLowStar.MemoryHelpers let cswap2 bit p0 p1 = DV.length_eq (get_downview p0); DV.length_eq (get_downview p1); let (x, _) = lowstar_cswap_normal_t bit p0 p1 () in () let cswap_comments : list string = ["Computes p1 <- bit ? p2 : p1 in constant time"]
false
true
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap_names (n: nat) : string
[]
Vale.Inline.X64.Fswap_inline.cswap_names
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat -> Prims.string
{ "end_col": 11, "end_line": 171, "start_col": 2, "start_line": 167 }
Prims.Tot
val cswap_comments:list string
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap_comments : list string = ["Computes p1 <- bit ? p2 : p1 in constant time"]
val cswap_comments:list string let cswap_comments:list string =
false
null
false
["Computes p1 <- bit ? p2 : p1 in constant time"]
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Prims.Cons", "Prims.string", "Prims.Nil" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the cswap wrapper *) [@__reduce__] let lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) (* And here's the cswap wrapper itself *) let lowstar_cswap : lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) let lowstar_cswap_normal_t : normal lowstar_cswap_t = as_normal_t #lowstar_cswap_t lowstar_cswap open Vale.AsLowStar.MemoryHelpers let cswap2 bit p0 p1 = DV.length_eq (get_downview p0); DV.length_eq (get_downview p1); let (x, _) = lowstar_cswap_normal_t bit p0 p1 () in ()
false
true
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap_comments:list string
[]
Vale.Inline.X64.Fswap_inline.cswap_comments
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.list Prims.string
{ "end_col": 51, "end_line": 164, "start_col": 2, "start_line": 164 }
Prims.Tot
val lowstar_cswap_normal_t:normal lowstar_cswap_t
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lowstar_cswap_normal_t : normal lowstar_cswap_t = as_normal_t #lowstar_cswap_t lowstar_cswap
val lowstar_cswap_normal_t:normal lowstar_cswap_t let lowstar_cswap_normal_t:normal lowstar_cswap_t =
false
null
false
as_normal_t #lowstar_cswap_t lowstar_cswap
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Inline.X64.Fswap_inline.as_normal_t", "Vale.Inline.X64.Fswap_inline.lowstar_cswap_t", "Vale.Inline.X64.Fswap_inline.lowstar_cswap" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the cswap wrapper *) [@__reduce__] let lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) (* And here's the cswap wrapper itself *) let lowstar_cswap : lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win))
false
false
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowstar_cswap_normal_t:normal lowstar_cswap_t
[]
Vale.Inline.X64.Fswap_inline.lowstar_cswap_normal_t
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.Pervasives.norm [ FStar.Pervasives.iota; FStar.Pervasives.zeta; FStar.Pervasives.delta_attr ["Vale.Arch.HeapTypes_s.__reduce__"; "FStar.BigOps.__reduce__"]; FStar.Pervasives.delta_only [ "Vale.Interop.Base.uu___is_TD_Buffer"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace"; "FStar.FunctionalExtensionality.on_dom"; "FStar.FunctionalExtensionality.on"; "FStar.List.Tot.Base.fold_right_gtot"; "FStar.List.Tot.Base.map_gtot"; "FStar.List.Tot.Base.length"; "FStar.Pervasives.Native.fst"; "FStar.Pervasives.Native.snd"; "FStar.Pervasives.Native.__proj__Mktuple2__item___1"; "FStar.Pervasives.Native.__proj__Mktuple2__item___2" ]; FStar.Pervasives.primops; FStar.Pervasives.simplify ] Vale.Inline.X64.Fswap_inline.lowstar_cswap_t <: Type0
{ "end_col": 46, "end_line": 153, "start_col": 4, "start_line": 153 }
Prims.Tot
val as_normal_t (#a: Type) (x: a) : normal a
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let as_normal_t (#a:Type) (x:a) : normal a = x
val as_normal_t (#a: Type) (x: a) : normal a let as_normal_t (#a: Type) (x: a) : normal a =
false
null
false
x
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Interop.Base.normal" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *)
false
false
Vale.Inline.X64.Fswap_inline.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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val as_normal_t (#a: Type) (x: a) : normal a
[]
Vale.Inline.X64.Fswap_inline.as_normal_t
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: a -> Vale.Interop.Base.normal a
{ "end_col": 46, "end_line": 29, "start_col": 45, "start_line": 29 }
Prims.Tot
val as_t (#a: Type) (x: normal a) : a
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let as_t (#a:Type) (x:normal a) : a = x
val as_t (#a: Type) (x: normal a) : a let as_t (#a: Type) (x: normal a) : a =
false
null
false
x
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Interop.Base.normal" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t
false
false
Vale.Inline.X64.Fswap_inline.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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val as_t (#a: Type) (x: normal a) : a
[]
Vale.Inline.X64.Fswap_inline.as_t
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Interop.Base.normal a -> a
{ "end_col": 39, "end_line": 28, "start_col": 38, "start_line": 28 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win))
let lowstar_cswap_t =
false
null
false
assert_norm (List.length cswap_dom + List.length ([] <: list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom [] _ _ (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win))
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Interop.X64.as_lowstar_sig_t_weak", "Vale.Inline.X64.Fswap_inline.arg_reg", "Vale.Inline.X64.Fswap_inline.cswap_regs_modified", "Vale.Inline.X64.Fswap_inline.cswap_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fswap_inline.code_cswap", "Vale.Inline.X64.Fswap_inline.cswap_dom", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Vale.Inline.X64.Fswap_inline.cswap_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Inline.X64.Fswap_inline.cswap_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Inline.X64.Fswap_inline.cswap_lemma", "Vale.Interop.Assumptions.win", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the cswap wrapper *) [@__reduce__]
false
true
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowstar_cswap_t : Type0
[]
Vale.Inline.X64.Fswap_inline.lowstar_cswap_t
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 77, "end_line": 138, "start_col": 2, "start_line": 126 }
Prims.Tot
val cswap_dom:IX64.arity_ok 3 td
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y
val cswap_dom:IX64.arity_ok 3 td let cswap_dom:IX64.arity_ok 3 td =
false
null
false
let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list", "Prims.Cons", "Vale.Inline.X64.Fswap_inline.tuint64", "Vale.Inline.X64.Fswap_inline.t64_mod", "Prims.Nil" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64
false
false
Vale.Inline.X64.Fswap_inline.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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap_dom:IX64.arity_ok 3 td
[]
Vale.Inline.X64.Fswap_inline.cswap_dom
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Interop.X64.arity_ok 3 Vale.Interop.Base.td
{ "end_col": 3, "end_line": 44, "start_col": 35, "start_line": 41 }
Prims.Tot
val cswap_regs_modified: MS.reg_64 -> bool
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false
val cswap_regs_modified: MS.reg_64 -> bool let cswap_regs_modified: MS.reg_64 -> bool =
false
null
false
fun (r: MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.reg_64", "Prims.op_BarBar", "Prims.op_Equality", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rR8", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rR10", "Prims.bool" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50"
false
true
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap_regs_modified: MS.reg_64 -> bool
[]
Vale.Inline.X64.Fswap_inline.cswap_regs_modified
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r: Vale.X64.Machine_s.reg_64 -> Prims.bool
{ "end_col": 12, "end_line": 73, "start_col": 45, "start_line": 70 }
Prims.Tot
val of_arg (i: IX64.reg_nat 3) : MS.reg_64
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx
val of_arg (i: IX64.reg_nat 3) : MS.reg_64 let of_arg (i: IX64.reg_nat 3) : MS.reg_64 =
false
null
false
match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Interop.X64.reg_nat", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.reg_64" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None
false
false
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val of_arg (i: IX64.reg_nat 3) : MS.reg_64
[]
Vale.Inline.X64.Fswap_inline.of_arg
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Vale.Interop.X64.reg_nat 3 -> Vale.X64.Machine_s.reg_64
{ "end_col": 16, "end_line": 119, "start_col": 44, "start_line": 116 }
Prims.Tot
val arg_reg:IX64.arg_reg_relation 3
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg
val arg_reg:IX64.arg_reg_relation 3 let arg_reg:IX64.arg_reg_relation 3 =
false
null
false
IX64.Rel of_reg of_arg
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Interop.X64.Rel", "Vale.Inline.X64.Fswap_inline.of_reg", "Vale.Inline.X64.Fswap_inline.of_arg" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx
false
false
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val arg_reg:IX64.arg_reg_relation 3
[]
Vale.Inline.X64.Fswap_inline.arg_reg
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
v: Vale.Interop.X64.arg_reg_relation' 3 { forall (r: Vale.X64.Machine_s.reg_64). {:pattern Rel?.of_reg v r} Some? (Rel?.of_reg v r) ==> Rel?.of_arg v (Some?.v (Rel?.of_reg v r)) = r }
{ "end_col": 62, "end_line": 121, "start_col": 40, "start_line": 121 }
Prims.Tot
val lowstar_cswap:lowstar_cswap_t
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lowstar_cswap : lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win))
val lowstar_cswap:lowstar_cswap_t let lowstar_cswap:lowstar_cswap_t =
false
null
false
assert_norm (List.length cswap_dom + List.length ([] <: list arg) <= 3); IX64.wrap_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win))
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Interop.X64.wrap_weak", "Vale.Inline.X64.Fswap_inline.arg_reg", "Vale.Inline.X64.Fswap_inline.cswap_regs_modified", "Vale.Inline.X64.Fswap_inline.cswap_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fswap_inline.code_cswap", "Vale.Inline.X64.Fswap_inline.cswap_dom", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.Inline.X64.Fswap_inline.cswap_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Inline.X64.Fswap_inline.cswap_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Inline.X64.Fswap_inline.cswap_lemma", "Vale.Interop.Assumptions.win", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the cswap wrapper *) [@__reduce__] let lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) (* And here's the cswap wrapper itself *)
false
true
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowstar_cswap:lowstar_cswap_t
[]
Vale.Inline.X64.Fswap_inline.lowstar_cswap
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Inline.X64.Fswap_inline.lowstar_cswap_t
{ "end_col": 77, "end_line": 150, "start_col": 2, "start_line": 142 }
FStar.All.ML
val cswap2_code_inline: Prims.unit -> FStar.All.ML int
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap2_code_inline () : FStar.All.ML int = PR.print_inline "cswap2" 0 None (List.length cswap_dom) cswap_dom cswap_names code_cswap of_arg cswap_regs_modified cswap_comments
val cswap2_code_inline: Prims.unit -> FStar.All.ML int let cswap2_code_inline () : FStar.All.ML int =
true
null
false
PR.print_inline "cswap2" 0 None (List.length cswap_dom) cswap_dom cswap_names code_cswap of_arg cswap_regs_modified cswap_comments
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "ml" ]
[ "Prims.unit", "Vale.X64.Print_Inline_s.print_inline", "FStar.Pervasives.Native.None", "Prims.string", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Vale.Inline.X64.Fswap_inline.cswap_dom", "Vale.Inline.X64.Fswap_inline.cswap_names", "Vale.Inline.X64.Fswap_inline.code_cswap", "Vale.Inline.X64.Fswap_inline.of_arg", "Vale.Inline.X64.Fswap_inline.cswap_regs_modified", "Vale.Inline.X64.Fswap_inline.cswap_comments", "Prims.int" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the cswap wrapper *) [@__reduce__] let lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) (* And here's the cswap wrapper itself *) let lowstar_cswap : lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) let lowstar_cswap_normal_t : normal lowstar_cswap_t = as_normal_t #lowstar_cswap_t lowstar_cswap open Vale.AsLowStar.MemoryHelpers let cswap2 bit p0 p1 = DV.length_eq (get_downview p0); DV.length_eq (get_downview p1); let (x, _) = lowstar_cswap_normal_t bit p0 p1 () in () let cswap_comments : list string = ["Computes p1 <- bit ? p2 : p1 in constant time"] let cswap_names (n:nat) : string = match n with | 0 -> "bit" | 1 -> "p1" | 2 -> "p2" | _ -> ""
false
false
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap2_code_inline: Prims.unit -> FStar.All.ML int
[]
Vale.Inline.X64.Fswap_inline.cswap2_code_inline
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.All.ML Prims.int
{ "end_col": 132, "end_line": 174, "start_col": 2, "start_line": 174 }
Prims.Tot
val cswap_post:VSig.vale_post cswap_dom
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f
val cswap_post:VSig.vale_post cswap_dom let cswap_post:VSig.vale_post cswap_dom =
false
null
false
fun (c: V.va_code) (bit: uint64) (p0: b64) (p1: b64) (va_s0: V.va_state) (va_s1: V.va_state) (f: V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_code", "Vale.Inline.X64.Fswap_inline.uint64", "Vale.Inline.X64.Fswap_inline.b64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.Curve25519.X64.FastUtil.va_ens_Cswap2", "FStar.UInt64.v", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Prims.prop" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__]
false
true
Vale.Inline.X64.Fswap_inline.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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap_post:VSig.vale_post cswap_dom
[]
Vale.Inline.X64.Fswap_inline.cswap_post
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.AsLowStar.ValeSig.vale_post Vale.Inline.X64.Fswap_inline.cswap_dom
{ "end_col": 93, "end_line": 66, "start_col": 2, "start_line": 59 }
Prims.Tot
val cswap_pre:VSig.vale_pre cswap_dom
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1)
val cswap_pre:VSig.vale_pre cswap_dom let cswap_pre:VSig.vale_pre cswap_dom =
false
null
false
fun (c: V.va_code) (bit: uint64) (p0: b64) (p1: b64) (va_s0: V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1)
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.X64.Decls.va_code", "Vale.Inline.X64.Fswap_inline.uint64", "Vale.Inline.X64.Fswap_inline.b64", "Vale.X64.Decls.va_state", "Vale.Curve25519.X64.FastUtil.va_req_Cswap2", "FStar.UInt64.v", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Prims.prop" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__]
false
true
Vale.Inline.X64.Fswap_inline.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": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap_pre:VSig.vale_pre cswap_dom
[]
Vale.Inline.X64.Fswap_inline.cswap_pre
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.AsLowStar.ValeSig.vale_pre Vale.Inline.X64.Fswap_inline.cswap_dom
{ "end_col": 62, "end_line": 55, "start_col": 2, "start_line": 49 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma'
let cswap_lemma =
false
null
false
as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma'
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ "total" ]
[ "Vale.Inline.X64.Fswap_inline.as_t", "Vale.AsLowStar.ValeSig.vale_sig", "Vale.Inline.X64.Fswap_inline.cswap_dom", "Vale.Inline.X64.Fswap_inline.cswap_regs_modified", "Vale.Inline.X64.Fswap_inline.cswap_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fswap_inline.cswap_pre", "Vale.Inline.X64.Fswap_inline.cswap_post", "Vale.Inline.X64.Fswap_inline.cswap_lemma'" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f)
false
true
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap_lemma : Vale.AsLowStar.ValeSig.vale_sig Vale.Inline.X64.Fswap_inline.cswap_regs_modified Vale.Inline.X64.Fswap_inline.cswap_xmms_modified Vale.Inline.X64.Fswap_inline.cswap_pre Vale.Inline.X64.Fswap_inline.cswap_post
[]
Vale.Inline.X64.Fswap_inline.cswap_lemma
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.AsLowStar.ValeSig.vale_sig Vale.Inline.X64.Fswap_inline.cswap_regs_modified Vale.Inline.X64.Fswap_inline.cswap_xmms_modified Vale.Inline.X64.Fswap_inline.cswap_pre Vale.Inline.X64.Fswap_inline.cswap_post
{ "end_col": 113, "end_line": 106, "start_col": 18, "start_line": 106 }
Prims.Ghost
val cswap_lemma' (code: V.va_code) (_win: bool) (bit: uint64) (p0 p1: b64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)))
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f)
val cswap_lemma' (code: V.va_code) (_win: bool) (bit: uint64) (p0 p1: b64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1))) let cswap_lemma' (code: V.va_code) (_win: bool) (bit: uint64) (p0 p1: b64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1))) =
false
null
false
let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f)
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[]
[ "Vale.X64.Decls.va_code", "Prims.bool", "Vale.Inline.X64.Fswap_inline.uint64", "Vale.Inline.X64.Fswap_inline.b64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal", "Vale.Arch.HeapTypes_s.TUInt64", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.Curve25519.X64.FastUtil.va_lemma_Cswap2", "FStar.UInt64.v", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Inline.X64.Fswap_inline.cswap_pre", "Prims.l_and", "Vale.X64.Decls.eval_code", "Vale.AsLowStar.ValeSig.vale_calling_conventions", "Vale.Inline.X64.Fswap_inline.cswap_regs_modified", "Vale.Inline.X64.Fswap_inline.cswap_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fswap_inline.cswap_post", "Vale.X64.Memory.buffer_readable", "Vale.X64.State.vs_get_vale_heap", "Vale.X64.Memory.buffer_writeable", "Vale.X64.Memory.modifies", "Vale.X64.Memory.loc_union", "Vale.X64.Memory.loc_buffer", "Vale.X64.Memory.loc_none" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1))
false
false
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap_lemma' (code: V.va_code) (_win: bool) (bit: uint64) (p0 p1: b64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)))
[]
Vale.Inline.X64.Fswap_inline.cswap_lemma'
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
code: Vale.X64.Decls.va_code -> _win: Prims.bool -> bit: Vale.Inline.X64.Fswap_inline.uint64 -> p0: Vale.Inline.X64.Fswap_inline.b64 -> p1: Vale.Inline.X64.Fswap_inline.b64 -> va_s0: Vale.X64.Decls.va_state -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 13, "end_line": 103, "start_col": 5, "start_line": 99 }
FStar.HyperStack.ST.Stack
val cswap2 (bit:UInt64.t{UInt64.v bit <= 1}) (p0:u512) (p1:u512) : Stack unit (requires fun h -> B.live h p0 /\ B.live h p1 /\ (B.disjoint p0 p1 \/ p0 == p1)) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer p0) (B.loc_buffer p1)) h0 h1 /\ (let old_p0 = B.as_seq h0 p0 in let new_p0 = B.as_seq h1 p0 in let old_p1 = B.as_seq h0 p1 in let new_p1 = B.as_seq h1 p1 in (UInt64.v bit = 1 ==> (Seq.equal old_p0 new_p1 /\ Seq.equal old_p1 new_p0)) /\ (UInt64.v bit = 0 ==> (Seq.equal old_p0 new_p0 /\ Seq.equal old_p1 new_p1)) ) )
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap2 bit p0 p1 = DV.length_eq (get_downview p0); DV.length_eq (get_downview p1); let (x, _) = lowstar_cswap_normal_t bit p0 p1 () in ()
val cswap2 (bit:UInt64.t{UInt64.v bit <= 1}) (p0:u512) (p1:u512) : Stack unit (requires fun h -> B.live h p0 /\ B.live h p1 /\ (B.disjoint p0 p1 \/ p0 == p1)) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer p0) (B.loc_buffer p1)) h0 h1 /\ (let old_p0 = B.as_seq h0 p0 in let new_p0 = B.as_seq h1 p0 in let old_p1 = B.as_seq h0 p1 in let new_p1 = B.as_seq h1 p1 in (UInt64.v bit = 1 ==> (Seq.equal old_p0 new_p1 /\ Seq.equal old_p1 new_p0)) /\ (UInt64.v bit = 0 ==> (Seq.equal old_p0 new_p0 /\ Seq.equal old_p1 new_p1)) ) ) let cswap2 bit p0 p1 =
true
null
false
DV.length_eq (get_downview p0); DV.length_eq (get_downview p1); let x, _ = lowstar_cswap_normal_t bit p0 p1 () in ()
{ "checked_file": "Vale.Inline.X64.Fswap_inline.fst.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[]
[ "FStar.UInt64.t", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt64.v", "Vale.Inline.X64.Fswap_inline.u512", "FStar.Ghost.erased", "Vale.Interop.X64.as_lowstar_sig_ret", "Prims.unit", "Vale.Interop.X64.als_ret", "Vale.Inline.X64.Fswap_inline.lowstar_cswap_normal_t", "LowStar.BufferView.Down.length_eq", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Arch.HeapTypes_s.TUInt64", "LowStar.Buffer.trivial_preorder" ]
[]
module Vale.Inline.X64.Fswap_inline open FStar.Mul open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the cswap wrapper *) [@__reduce__] let lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) (* And here's the cswap wrapper itself *) let lowstar_cswap : lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) let lowstar_cswap_normal_t : normal lowstar_cswap_t = as_normal_t #lowstar_cswap_t lowstar_cswap open Vale.AsLowStar.MemoryHelpers
false
false
Vale.Inline.X64.Fswap_inline.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap2 (bit:UInt64.t{UInt64.v bit <= 1}) (p0:u512) (p1:u512) : Stack unit (requires fun h -> B.live h p0 /\ B.live h p1 /\ (B.disjoint p0 p1 \/ p0 == p1)) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer p0) (B.loc_buffer p1)) h0 h1 /\ (let old_p0 = B.as_seq h0 p0 in let new_p0 = B.as_seq h1 p0 in let old_p1 = B.as_seq h0 p1 in let new_p1 = B.as_seq h1 p1 in (UInt64.v bit = 1 ==> (Seq.equal old_p0 new_p1 /\ Seq.equal old_p1 new_p0)) /\ (UInt64.v bit = 0 ==> (Seq.equal old_p0 new_p0 /\ Seq.equal old_p1 new_p1)) ) )
[]
Vale.Inline.X64.Fswap_inline.cswap2
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bit: FStar.UInt64.t{FStar.UInt64.v bit <= 1} -> p0: Vale.Inline.X64.Fswap_inline.u512 -> p1: Vale.Inline.X64.Fswap_inline.u512 -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 6, "end_line": 161, "start_col": 4, "start_line": 158 }
Prims.Tot
val pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) (v:a) : vprop
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback]v:a) = to_vprop (Steel.Memory.pts_to r v)
val pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) (v:a) : vprop let pts_to (#a: Type u#1) (#pcm: pcm a) (r: ref a pcm) ([@@@ smt_fallback]v: a) =
false
null
false
to_vprop (Steel.Memory.pts_to r v)
{ "checked_file": "Steel.GhostPCMReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.PCMReference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostPCMReference.fst" }
[ "total" ]
[ "FStar.PCM.pcm", "Steel.GhostPCMReference.ref", "Steel.Effect.Common.to_vprop", "Steel.Memory.pts_to", "FStar.Ghost.reveal", "Steel.Memory.ref", "Steel.Effect.Common.vprop" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostPCMReference (* A ghost variant of Steel.PCMReference *) open FStar.PCM open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Mem = Steel.Memory module P = Steel.PCMReference let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p) /// Its selector is non-informative (it is unit) [@@__reduce__]
false
false
Steel.GhostPCMReference.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) (v:a) : vprop
[]
Steel.GhostPCMReference.pts_to
{ "file_name": "lib/steel/Steel.GhostPCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostPCMReference.ref a pcm -> v: a -> Steel.Effect.Common.vprop
{ "end_col": 38, "end_line": 32, "start_col": 4, "start_line": 32 }
Prims.Tot
val ref (a:Type) (p:pcm a) : Type0
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p)
val ref (a:Type) (p:pcm a) : Type0 let ref (a: Type) (p: pcm a) =
false
null
false
erased (Steel.Memory.ref a p)
{ "checked_file": "Steel.GhostPCMReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.PCMReference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostPCMReference.fst" }
[ "total" ]
[ "FStar.PCM.pcm", "FStar.Ghost.erased", "Steel.Memory.ref" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostPCMReference (* A ghost variant of Steel.PCMReference *) open FStar.PCM open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Mem = Steel.Memory module P = Steel.PCMReference
false
false
Steel.GhostPCMReference.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ref (a:Type) (p:pcm a) : Type0
[]
Steel.GhostPCMReference.ref
{ "file_name": "lib/steel/Steel.GhostPCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Type -> p: FStar.PCM.pcm a -> Type0
{ "end_col": 58, "end_line": 27, "start_col": 29, "start_line": 27 }
Prims.Tot
val witnessed (#a:Type u#1) (#p:pcm a) (r:ref a p) (fact:property a) : Type0
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let witnessed (#a:Type) (#p:pcm a) (r:ref a p) (fact:property a) : Type0 = Steel.Memory.witnessed r fact
val witnessed (#a:Type u#1) (#p:pcm a) (r:ref a p) (fact:property a) : Type0 let witnessed (#a: Type) (#p: pcm a) (r: ref a p) (fact: property a) : Type0 =
false
null
false
Steel.Memory.witnessed r fact
{ "checked_file": "Steel.GhostPCMReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.PCMReference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostPCMReference.fst" }
[ "total" ]
[ "FStar.PCM.pcm", "Steel.GhostPCMReference.ref", "Steel.Memory.property", "Steel.Memory.witnessed", "FStar.Ghost.reveal", "Steel.Memory.ref" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostPCMReference (* A ghost variant of Steel.PCMReference *) open FStar.PCM open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Mem = Steel.Memory module P = Steel.PCMReference let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p) /// Its selector is non-informative (it is unit) [@@__reduce__] let pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback]v:a) = to_vprop (Steel.Memory.pts_to r v) let alloc (#o:inames) (#a:Type) (#pcm:pcm a) (x:a) : SteelGhost (ref a pcm) o (emp) (fun r -> pts_to r x) (requires fun _ -> pcm.refine x) (ensures fun _ _ _ -> True) = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); FStar.PCM.compatible_refl pcm x; let r = as_atomic_action_ghost (alloc_action o x) in r let read (#o:inames) (#a:Type) (#pcm:pcm a) (#v0:a) (r:ref a pcm) : SteelGhost a o (pts_to r v0) (fun _ -> pts_to r v0) (requires fun _ -> True) (ensures fun _ v _ -> compatible pcm v0 v) = let v = as_atomic_action_ghost (sel_action o r v0) in v let write (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v0) (fun _ -> pts_to r v1) (requires fun _ -> frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ _ _ -> True) = as_atomic_action_ghost (upd_action o r v0 v1) let upd_gen (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (x y:a) (f:frame_preserving_upd p x y) : SteelGhostT unit o (pts_to r x) (fun _ -> pts_to r y) = as_atomic_action_ghost (Steel.Memory.upd_gen o r x y f) let share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True) = P.split r v v0 v1 let gather (#o:inames) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:a) (v1:a) : SteelGhostT (_:unit{composable p v0 v1}) o (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1)) = P.gather r v0 v1 let witnessed (#a:Type) (#p:pcm a) (r:ref a p) (fact:property a)
false
false
Steel.GhostPCMReference.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val witnessed (#a:Type u#1) (#p:pcm a) (r:ref a p) (fact:property a) : Type0
[]
Steel.GhostPCMReference.witnessed
{ "file_name": "lib/steel/Steel.GhostPCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostPCMReference.ref a p -> fact: Steel.Memory.property a -> Type0
{ "end_col": 33, "end_line": 115, "start_col": 4, "start_line": 115 }
Steel.Effect.Atomic.SteelAtomicU
val recall (#o: _) (#a:Type) (#pcm:pcm a) (fact:property a) (r:ref a pcm) (v:erased a) (w:witnessed r fact) : SteelAtomicU (erased a) o (pts_to r v) (fun v1 -> pts_to r v) (requires fun _ -> True) (ensures fun _ v1 _ -> fact v1 /\ compatible pcm v v1)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let recall (#o: _) (#a:Type) (#pcm:pcm a) (fact:property a) (r:ref a pcm) (v:erased a) (w:witnessed r fact) = P.recall fact r v w
val recall (#o: _) (#a:Type) (#pcm:pcm a) (fact:property a) (r:ref a pcm) (v:erased a) (w:witnessed r fact) : SteelAtomicU (erased a) o (pts_to r v) (fun v1 -> pts_to r v) (requires fun _ -> True) (ensures fun _ v1 _ -> fact v1 /\ compatible pcm v v1) let recall (#o: _) (#a: Type) (#pcm: pcm a) (fact: property a) (r: ref a pcm) (v: erased a) (w: witnessed r fact) =
true
null
false
P.recall fact r v w
{ "checked_file": "Steel.GhostPCMReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.PCMReference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostPCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.property", "Steel.GhostPCMReference.ref", "FStar.Ghost.erased", "Steel.GhostPCMReference.witnessed", "Steel.PCMReference.recall" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostPCMReference (* A ghost variant of Steel.PCMReference *) open FStar.PCM open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Mem = Steel.Memory module P = Steel.PCMReference let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p) /// Its selector is non-informative (it is unit) [@@__reduce__] let pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback]v:a) = to_vprop (Steel.Memory.pts_to r v) let alloc (#o:inames) (#a:Type) (#pcm:pcm a) (x:a) : SteelGhost (ref a pcm) o (emp) (fun r -> pts_to r x) (requires fun _ -> pcm.refine x) (ensures fun _ _ _ -> True) = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); FStar.PCM.compatible_refl pcm x; let r = as_atomic_action_ghost (alloc_action o x) in r let read (#o:inames) (#a:Type) (#pcm:pcm a) (#v0:a) (r:ref a pcm) : SteelGhost a o (pts_to r v0) (fun _ -> pts_to r v0) (requires fun _ -> True) (ensures fun _ v _ -> compatible pcm v0 v) = let v = as_atomic_action_ghost (sel_action o r v0) in v let write (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v0) (fun _ -> pts_to r v1) (requires fun _ -> frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ _ _ -> True) = as_atomic_action_ghost (upd_action o r v0 v1) let upd_gen (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (x y:a) (f:frame_preserving_upd p x y) : SteelGhostT unit o (pts_to r x) (fun _ -> pts_to r y) = as_atomic_action_ghost (Steel.Memory.upd_gen o r x y f) let share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True) = P.split r v v0 v1 let gather (#o:inames) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:a) (v1:a) : SteelGhostT (_:unit{composable p v0 v1}) o (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1)) = P.gather r v0 v1 let witnessed (#a:Type) (#p:pcm a) (r:ref a p) (fact:property a) : Type0 = Steel.Memory.witnessed r fact let witness (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:Steel.Preorder.stable_property pcm) (v:erased a) (_:squash (Steel.Preorder.fact_valid_compat fact v)) = P.witness r fact v () let recall (#o: _) (#a:Type) (#pcm:pcm a) (fact:property a) (r:ref a pcm) (v:erased a)
false
false
Steel.GhostPCMReference.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val recall (#o: _) (#a:Type) (#pcm:pcm a) (fact:property a) (r:ref a pcm) (v:erased a) (w:witnessed r fact) : SteelAtomicU (erased a) o (pts_to r v) (fun v1 -> pts_to r v) (requires fun _ -> True) (ensures fun _ v1 _ -> fact v1 /\ compatible pcm v v1)
[]
Steel.GhostPCMReference.recall
{ "file_name": "lib/steel/Steel.GhostPCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
fact: Steel.Memory.property a -> r: Steel.GhostPCMReference.ref a pcm -> v: FStar.Ghost.erased a -> w: Steel.GhostPCMReference.witnessed r fact -> Steel.Effect.Atomic.SteelAtomicU (FStar.Ghost.erased a)
{ "end_col": 23, "end_line": 133, "start_col": 4, "start_line": 133 }
Steel.Effect.Atomic.SteelAtomicUT
val witness (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:Steel.Preorder.stable_property pcm) (v:erased a) (_:squash (Steel.Preorder.fact_valid_compat fact v)) : SteelAtomicUT (witnessed r fact) o (pts_to r v) (fun _ -> pts_to r v)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let witness (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:Steel.Preorder.stable_property pcm) (v:erased a) (_:squash (Steel.Preorder.fact_valid_compat fact v)) = P.witness r fact v ()
val witness (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:Steel.Preorder.stable_property pcm) (v:erased a) (_:squash (Steel.Preorder.fact_valid_compat fact v)) : SteelAtomicUT (witnessed r fact) o (pts_to r v) (fun _ -> pts_to r v) let witness (#o: inames) (#a: Type) (#pcm: pcm a) (r: ref a pcm) (fact: Steel.Preorder.stable_property pcm) (v: erased a) (_: squash (Steel.Preorder.fact_valid_compat fact v)) =
true
null
false
P.witness r fact v ()
{ "checked_file": "Steel.GhostPCMReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.PCMReference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostPCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.GhostPCMReference.ref", "Steel.Preorder.stable_property", "FStar.Ghost.erased", "Prims.squash", "Steel.Preorder.fact_valid_compat", "FStar.Ghost.reveal", "Steel.PCMReference.witness", "Steel.Memory.witnessed", "Steel.Memory.ref", "Steel.GhostPCMReference.witnessed" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostPCMReference (* A ghost variant of Steel.PCMReference *) open FStar.PCM open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Mem = Steel.Memory module P = Steel.PCMReference let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p) /// Its selector is non-informative (it is unit) [@@__reduce__] let pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback]v:a) = to_vprop (Steel.Memory.pts_to r v) let alloc (#o:inames) (#a:Type) (#pcm:pcm a) (x:a) : SteelGhost (ref a pcm) o (emp) (fun r -> pts_to r x) (requires fun _ -> pcm.refine x) (ensures fun _ _ _ -> True) = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); FStar.PCM.compatible_refl pcm x; let r = as_atomic_action_ghost (alloc_action o x) in r let read (#o:inames) (#a:Type) (#pcm:pcm a) (#v0:a) (r:ref a pcm) : SteelGhost a o (pts_to r v0) (fun _ -> pts_to r v0) (requires fun _ -> True) (ensures fun _ v _ -> compatible pcm v0 v) = let v = as_atomic_action_ghost (sel_action o r v0) in v let write (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v0) (fun _ -> pts_to r v1) (requires fun _ -> frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ _ _ -> True) = as_atomic_action_ghost (upd_action o r v0 v1) let upd_gen (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (x y:a) (f:frame_preserving_upd p x y) : SteelGhostT unit o (pts_to r x) (fun _ -> pts_to r y) = as_atomic_action_ghost (Steel.Memory.upd_gen o r x y f) let share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True) = P.split r v v0 v1 let gather (#o:inames) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:a) (v1:a) : SteelGhostT (_:unit{composable p v0 v1}) o (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1)) = P.gather r v0 v1 let witnessed (#a:Type) (#p:pcm a) (r:ref a p) (fact:property a) : Type0 = Steel.Memory.witnessed r fact let witness (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:Steel.Preorder.stable_property pcm) (v:erased a)
false
false
Steel.GhostPCMReference.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val witness (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:Steel.Preorder.stable_property pcm) (v:erased a) (_:squash (Steel.Preorder.fact_valid_compat fact v)) : SteelAtomicUT (witnessed r fact) o (pts_to r v) (fun _ -> pts_to r v)
[]
Steel.GhostPCMReference.witness
{ "file_name": "lib/steel/Steel.GhostPCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostPCMReference.ref a pcm -> fact: Steel.Preorder.stable_property pcm -> v: FStar.Ghost.erased a -> _: Prims.squash (Steel.Preorder.fact_valid_compat fact (FStar.Ghost.reveal v)) -> Steel.Effect.Atomic.SteelAtomicUT (Steel.GhostPCMReference.witnessed r fact)
{ "end_col": 25, "end_line": 124, "start_col": 4, "start_line": 124 }
Steel.Effect.Atomic.SteelGhost
val share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True) = P.split r v v0 v1
val share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True) let share (#o: inames) (#a: Type) (#p: pcm a) (r: ref a p) (v v0 v1: a) : SteelGhost unit o (pts_to r v) (fun _ -> (pts_to r v0) `star` (pts_to r v1)) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True) =
true
null
false
P.split r v v0 v1
{ "checked_file": "Steel.GhostPCMReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.PCMReference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostPCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.GhostPCMReference.ref", "Steel.PCMReference.split", "FStar.Ghost.reveal", "Steel.Memory.ref", "FStar.Ghost.hide", "Prims.unit", "Steel.GhostPCMReference.pts_to", "Steel.Effect.Common.star", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Prims.l_and", "FStar.PCM.composable", "Prims.eq2", "FStar.PCM.op", "Prims.l_True" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostPCMReference (* A ghost variant of Steel.PCMReference *) open FStar.PCM open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Mem = Steel.Memory module P = Steel.PCMReference let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p) /// Its selector is non-informative (it is unit) [@@__reduce__] let pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback]v:a) = to_vprop (Steel.Memory.pts_to r v) let alloc (#o:inames) (#a:Type) (#pcm:pcm a) (x:a) : SteelGhost (ref a pcm) o (emp) (fun r -> pts_to r x) (requires fun _ -> pcm.refine x) (ensures fun _ _ _ -> True) = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); FStar.PCM.compatible_refl pcm x; let r = as_atomic_action_ghost (alloc_action o x) in r let read (#o:inames) (#a:Type) (#pcm:pcm a) (#v0:a) (r:ref a pcm) : SteelGhost a o (pts_to r v0) (fun _ -> pts_to r v0) (requires fun _ -> True) (ensures fun _ v _ -> compatible pcm v0 v) = let v = as_atomic_action_ghost (sel_action o r v0) in v let write (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v0) (fun _ -> pts_to r v1) (requires fun _ -> frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ _ _ -> True) = as_atomic_action_ghost (upd_action o r v0 v1) let upd_gen (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (x y:a) (f:frame_preserving_upd p x y) : SteelGhostT unit o (pts_to r x) (fun _ -> pts_to r y) = as_atomic_action_ghost (Steel.Memory.upd_gen o r x y f) let share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1)
false
false
Steel.GhostPCMReference.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True)
[]
Steel.GhostPCMReference.share
{ "file_name": "lib/steel/Steel.GhostPCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostPCMReference.ref a p -> v: a -> v0: a -> v1: a -> Steel.Effect.Atomic.SteelGhost Prims.unit
{ "end_col": 21, "end_line": 100, "start_col": 4, "start_line": 100 }
Steel.Effect.Atomic.SteelGhostT
val gather (#o:inames) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:a) (v1:a) : SteelGhostT (_:unit{composable p v0 v1}) o (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1))
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gather (#o:inames) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:a) (v1:a) : SteelGhostT (_:unit{composable p v0 v1}) o (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1)) = P.gather r v0 v1
val gather (#o:inames) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:a) (v1:a) : SteelGhostT (_:unit{composable p v0 v1}) o (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1)) let gather (#o: inames) (#a: Type) (#p: FStar.PCM.pcm a) (r: ref a p) (v0 v1: a) : SteelGhostT (_: unit{composable p v0 v1}) o ((pts_to r v0) `star` (pts_to r v1)) (fun _ -> pts_to r (op p v0 v1)) =
true
null
false
P.gather r v0 v1
{ "checked_file": "Steel.GhostPCMReference.fst.checked", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.PCMReference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostPCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.GhostPCMReference.ref", "Steel.PCMReference.gather", "FStar.Ghost.reveal", "Steel.Memory.ref", "FStar.Ghost.hide", "Prims.unit", "FStar.PCM.composable", "Steel.Effect.Common.star", "Steel.GhostPCMReference.pts_to", "FStar.PCM.op", "Steel.Effect.Common.vprop" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostPCMReference (* A ghost variant of Steel.PCMReference *) open FStar.PCM open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Mem = Steel.Memory module P = Steel.PCMReference let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p) /// Its selector is non-informative (it is unit) [@@__reduce__] let pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback]v:a) = to_vprop (Steel.Memory.pts_to r v) let alloc (#o:inames) (#a:Type) (#pcm:pcm a) (x:a) : SteelGhost (ref a pcm) o (emp) (fun r -> pts_to r x) (requires fun _ -> pcm.refine x) (ensures fun _ _ _ -> True) = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); FStar.PCM.compatible_refl pcm x; let r = as_atomic_action_ghost (alloc_action o x) in r let read (#o:inames) (#a:Type) (#pcm:pcm a) (#v0:a) (r:ref a pcm) : SteelGhost a o (pts_to r v0) (fun _ -> pts_to r v0) (requires fun _ -> True) (ensures fun _ v _ -> compatible pcm v0 v) = let v = as_atomic_action_ghost (sel_action o r v0) in v let write (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v0) (fun _ -> pts_to r v1) (requires fun _ -> frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ _ _ -> True) = as_atomic_action_ghost (upd_action o r v0 v1) let upd_gen (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (x y:a) (f:frame_preserving_upd p x y) : SteelGhostT unit o (pts_to r x) (fun _ -> pts_to r y) = as_atomic_action_ghost (Steel.Memory.upd_gen o r x y f) let share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True) = P.split r v v0 v1 let gather (#o:inames) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:a) (v1:a) : SteelGhostT (_:unit{composable p v0 v1}) o (pts_to r v0 `star` pts_to r v1)
false
false
Steel.GhostPCMReference.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gather (#o:inames) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:a) (v1:a) : SteelGhostT (_:unit{composable p v0 v1}) o (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1))
[]
Steel.GhostPCMReference.gather
{ "file_name": "lib/steel/Steel.GhostPCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.GhostPCMReference.ref a p -> v0: a -> v1: a -> Steel.Effect.Atomic.SteelGhostT (_: Prims.unit{FStar.PCM.composable p v0 v1})
{ "end_col": 20, "end_line": 111, "start_col": 4, "start_line": 111 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
let modBits_t (t: limb_t) =
false
null
false
modBits: size_t{1 < v modBits /\ (2 * bits t) * SD.blocks (v modBits) (bits t) <= max_size_t}
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.IntTypes.max_size_t" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0"
false
true
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val modBits_t : t: Hacl.Bignum.Definitions.limb_t -> Type0
[]
Hacl.Impl.RSAPSS.modBits_t
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> Type0
{ "end_col": 117, "end_line": 36, "start_col": 27, "start_line": 36 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m))
let rsapss_verify_bn_to_msg_st (t: limb_t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: modBits_t t) =
false
null
false
saltLen: size_t -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> m: lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m))
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_verify_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Buffer.modifies0", "Prims.eq2", "Hacl.Spec.RSAPSS.rsapss_verify_bn_to_msg" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_verify_bn_to_msg_st : t: Hacl.Bignum.Definitions.limb_t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_verify_bn_to_msg_st
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
{ "end_col": 103, "end_line": 353, "start_col": 4, "start_line": 343 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
let rsapss_sign_msg_to_bn_st (t: limb_t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: modBits_t t) =
false
null
false
let len = blocks modBits (size (bits t)) in saltLen: size_t -> salt: lbuffer uint8 saltLen -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> m: lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Sequence.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Hacl.Spec.RSAPSS.rsapss_sign_pre", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Definitions.blocks", "Lib.IntTypes.bits", "Hacl.Spec.RSAPSS.rsapss_sign_msg_to_bn", "Lib.IntTypes.int_t", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_sign_msg_to_bn_st : t: Hacl.Bignum.Definitions.limb_t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_sign_msg_to_bn_st
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
{ "end_col": 114, "end_line": 104, "start_col": 104, "start_line": 90 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
let rsapss_verify_st (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: modBits_t t) =
false
null
false
let len = blocks modBits (size (bits t)) in eBits: size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey: lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen: size_t -> sgntLen: size_t -> sgnt: lbuffer uint8 sgntLen -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_pkey_pre", "Lib.Buffer.as_seq", "Lib.Buffer.modifies0", "Hacl.Spec.RSAPSS.rsapss_verify", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b inline_for_extraction noextract let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_verify_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_verify_st
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
{ "end_col": 74, "end_line": 488, "start_col": 110, "start_line": 471 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_pkey_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) = eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> nb:lbuffer uint8 (blocks modBits 8ul) -> eb:lbuffer uint8 (blocks eBits 8ul) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ disjoint msg sgnt /\ disjoint nb eb /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint msg nb /\ disjoint msg eb) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.rsapss_pkey_verify a (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
let rsapss_pkey_verify_st (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: size_t) =
false
null
false
eBits: size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> nb: lbuffer uint8 (blocks modBits 8ul) -> eb: lbuffer uint8 (blocks eBits 8ul) -> saltLen: size_t -> sgntLen: size_t -> sgnt: lbuffer uint8 sgntLen -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ disjoint msg sgnt /\ disjoint nb eb /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint msg nb /\ disjoint msg eb) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.rsapss_pkey_verify a (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.blocks", "FStar.UInt32.__uint_to_t", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.modifies0", "Spec.RSAPSS.rsapss_pkey_verify", "Lib.Buffer.as_seq" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b inline_for_extraction noextract let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res inline_for_extraction noextract let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); assert (v msgLen <= max_size_t); assert (v hLen + 8 < max_size_t); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && sgntLen =. blocks modBits 8ul in if b then rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg else false inline_for_extraction noextract let rsapss_skey_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) = eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> nb:lbuffer uint8 (blocks modBits 8ul) -> eb:lbuffer uint8 (blocks eBits 8ul) -> db:lbuffer uint8 (blocks dBits 8ul) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ live h db /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint sgnt db /\ disjoint salt msg) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (let sgnt_s = S.rsapss_skey_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) in if b then Some? sgnt_s /\ as_seq h1 sgnt == Some?.v sgnt_s else None? sgnt_s)) inline_for_extraction noextract val rsapss_skey_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits -> rsapss_sign:rsapss_sign_st t ke a modBits -> rsapss_skey_sign_st t ke a modBits let rsapss_skey_sign #t ke a modBits rsapss_load_skey rsapss_sign eBits dBits nb eb db saltLen salt msgLen msg sgnt = [@inline_let] let bits = size (bits t) in let h0 = ST.get () in push_frame (); let skey = create (2ul *! blocks modBits bits +! blocks eBits bits +! blocks dBits bits) (uint #t 0) in let b = rsapss_load_skey eBits dBits nb eb db skey in LS.rsapss_load_skey_lemma #t (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db); let res = if b then rsapss_sign eBits dBits skey saltLen salt msgLen msg sgnt else false in pop_frame (); let h1 = ST.get () in assert ((res, as_seq h1 sgnt) == LS.rsapss_skey_sign #t a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)); res inline_for_extraction noextract
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_pkey_verify_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Lib.IntTypes.size_t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_pkey_verify_st
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Lib.IntTypes.size_t -> Type0
{ "end_col": 74, "end_line": 592, "start_col": 4, "start_line": 576 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s))
let rsapss_verify_bn_st (t: limb_t) (ke: BE.exp t) (modBits: modBits_t t) =
false
null
false
let len = blocks modBits (size (bits t)) in eBits: size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey: lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def: lbignum t len -> s: lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s) )
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_pkey_pre", "Lib.Buffer.as_seq", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Definitions.lbignum", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_verify_bn", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_verify_bn_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_verify_bn_st
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
{ "end_col": 119, "end_line": 305, "start_col": 72, "start_line": 293 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt))
let rsapss_sign_st (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: modBits_t t) =
false
null
false
let len = blocks modBits (size (bits t)) in eBits: size_t -> dBits: size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey: lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen: size_t -> salt: lbuffer uint8 saltLen -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt))
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_skey_pre", "Lib.Buffer.as_seq", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.lseq", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_sign", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_sign_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_sign_st
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
{ "end_col": 96, "end_line": 247, "start_col": 108, "start_line": 228 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
let rsapss_sign_st1 (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: modBits_t t) =
false
null
false
let len = blocks modBits (size (bits t)) in eBits: size_t -> dBits: size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey: lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen: size_t -> salt: lbuffer uint8 saltLen -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_skey_pre", "Lib.Buffer.as_seq", "Hacl.Spec.RSAPSS.rsapss_sign_pre", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.lseq", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_sign_", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_sign_st1 : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_sign_st1
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
{ "end_col": 79, "end_line": 205, "start_col": 109, "start_line": 185 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_skey_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) = eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> nb:lbuffer uint8 (blocks modBits 8ul) -> eb:lbuffer uint8 (blocks eBits 8ul) -> db:lbuffer uint8 (blocks dBits 8ul) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ live h db /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint sgnt db /\ disjoint salt msg) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (let sgnt_s = S.rsapss_skey_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) in if b then Some? sgnt_s /\ as_seq h1 sgnt == Some?.v sgnt_s else None? sgnt_s))
let rsapss_skey_sign_st (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: size_t) =
false
null
false
eBits: size_t -> dBits: size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> nb: lbuffer uint8 (blocks modBits 8ul) -> eb: lbuffer uint8 (blocks eBits 8ul) -> db: lbuffer uint8 (blocks dBits 8ul) -> saltLen: size_t -> salt: lbuffer uint8 saltLen -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ live h db /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint sgnt db /\ disjoint salt msg) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (let sgnt_s = S.rsapss_skey_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) in if b then Some? sgnt_s /\ as_seq h1 sgnt == Some?.v sgnt_s else None? sgnt_s))
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.blocks", "FStar.UInt32.__uint_to_t", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.uu___is_Some", "Lib.ByteSequence.lbytes", "Spec.RSAPSS.blocks", "Lib.Sequence.seq", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.as_seq", "FStar.Pervasives.Native.__proj__Some__item__v", "FStar.Pervasives.Native.uu___is_None", "Prims.logical", "FStar.Pervasives.Native.option", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.RSAPSS.rsapss_skey_sign" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b inline_for_extraction noextract let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res inline_for_extraction noextract let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); assert (v msgLen <= max_size_t); assert (v hLen + 8 < max_size_t); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && sgntLen =. blocks modBits 8ul in if b then rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg else false inline_for_extraction noextract
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_skey_sign_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Lib.IntTypes.size_t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_skey_sign_st
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Lib.IntTypes.size_t -> Type0
{ "end_col": 82, "end_line": 540, "start_col": 4, "start_line": 519 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
let rsapss_verify_st1 (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: modBits_t t) =
false
null
false
let len = blocks modBits (size (bits t)) in eBits: size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey: lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen: size_t -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_pkey_pre", "Lib.Buffer.as_seq", "Hacl.Spec.RSAPSS.rsapss_verify_pre", "Lib.Buffer.modifies0", "Hacl.Spec.RSAPSS.rsapss_verify_", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_verify_st1 : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_verify_st1
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
{ "end_col": 62, "end_line": 448, "start_col": 111, "start_line": 431 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt))
let rsapss_verify_compute_msg_st (t: limb_t) (ke: BE.exp t) (modBits: modBits_t t) =
false
null
false
let len = blocks modBits (size (bits t)) in eBits: size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey: lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> m: lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt))
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Lib.Sequence.lseq", "Lib.Buffer.as_seq", "Lib.Sequence.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Hacl.Spec.RSAPSS.rsapss_pkey_pre", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Definitions.lbignum", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_verify_compute_msg", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_verify_compute_msg_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_verify_compute_msg_st
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
{ "end_col": 109, "end_line": 401, "start_col": 81, "start_line": 388 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
let rsapss_sign_bn_st (t: limb_t) (ke: BE.exp t) (modBits: modBits_t t) =
false
null
false
let len = blocks modBits (size (bits t)) in eBits: size_t -> dBits: size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey: lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m: lbignum t len -> m': lbignum t len -> s: lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_skey_pre", "Lib.Buffer.as_seq", "Hacl.Bignum.Definitions.bn_v", "Lib.Buffer.gsub", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Definitions.lbignum", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_sign_bn", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_sign_bn_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_sign_bn_st
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
{ "end_col": 105, "end_line": 56, "start_col": 70, "start_line": 40 }
Prims.Tot
val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); assert (v msgLen <= max_size_t); assert (v hLen + 8 < max_size_t); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && sgntLen =. blocks modBits 8ul in if b then rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg else false
val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg =
false
null
false
let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; assert (v msgLen <= max_size_t); assert (v hLen + 8 < max_size_t); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && sgntLen =. blocks modBits 8ul in if b then rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg else false
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.RSAPSS.rsapss_verify_", "Prims.bool", "Prims.op_AmpAmp", "Lib.IntTypes.op_Less_Equals_Dot", "Lib.IntTypes.op_Subtraction_Bang", "Lib.IntTypes.op_Equals_Dot", "Prims.unit", "Prims._assert", "Prims.op_LessThan", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Prims.op_LessThanOrEqual", "FStar.Math.Lemmas.pow2_lt_compat", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_GreaterThan", "Spec.Hash.Definitions.hash_length", "Hacl.Impl.RSAPSS.MGF.hash_len" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b inline_for_extraction noextract let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res inline_for_extraction noextract let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits
[]
Hacl.Impl.RSAPSS.rsapss_verify
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_verify_st t ke a modBits
{ "end_col": 9, "end_line": 514, "start_col": 78, "start_line": 499 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
let rsapss_sign_compute_sgnt_st (t: limb_t) (ke: BE.exp t) (modBits: modBits_t t) =
false
null
false
let len = blocks modBits (size (bits t)) in eBits: size_t -> dBits: size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey: lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m: lbignum t len -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m) )
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_skey_pre", "Lib.Buffer.as_seq", "Hacl.Bignum.Definitions.bn_v", "Lib.Buffer.gsub", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.lseq", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_sign_compute_sgnt", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame ()
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_sign_compute_sgnt_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
[]
Hacl.Impl.RSAPSS.rsapss_sign_compute_sgnt_st
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
{ "end_col": 121, "end_line": 154, "start_col": 80, "start_line": 140 }
FStar.HyperStack.ST.Stack
val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end
val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m =
true
null
false
if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.op_Negation", "Lib.IntTypes.op_Equals_Dot", "Lib.IntTypes.op_Percent_Dot", "Lib.IntTypes.op_Subtraction_Bang", "FStar.UInt32.__uint_to_t", "Prims.bool", "Hacl.Spec.Bignum.Base.unsafe_bool_of_limb0", "Hacl.Bignum.Definitions.limb", "Hacl.Bignum.bn_get_ith_bit" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
[]
Hacl.Impl.RSAPSS.bn_lt_pow2
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
modBits: Lib.IntTypes.size_t{1 < Lib.IntTypes.v modBits} -> m: Hacl.Bignum.Definitions.lbignum t (Hacl.Bignum.Definitions.blocks modBits (Lib.IntTypes.size (Lib.IntTypes.bits t))) -> FStar.HyperStack.ST.Stack Prims.bool
{ "end_col": 39, "end_line": 289, "start_col": 2, "start_line": 286 }
Prims.Tot
val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false
val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
false
null
false
let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.RSAPSS.rsapss_sign_", "Prims.bool", "Prims.op_AmpAmp", "Lib.IntTypes.op_Less_Equals_Dot", "Lib.IntTypes.op_Subtraction_Bang", "Prims.unit", "FStar.Math.Lemmas.pow2_lt_compat", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_GreaterThan", "Spec.Hash.Definitions.hash_length", "Hacl.Impl.RSAPSS.MGF.hash_len" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits
[]
Hacl.Impl.RSAPSS.rsapss_sign
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_sign_st t ke a modBits
{ "end_col": 9, "end_line": 271, "start_col": 79, "start_line": 258 }
Prims.Tot
val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res
val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s =
false
null
false
[@@ inline_let ]let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then (Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false) else false in res
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.bool", "Hacl.Spec.Bignum.Base.unsafe_bool_of_limb", "Hacl.Impl.RSAPSS.bn_lt_pow2", "Prims.unit", "Hacl.Spec.Bignum.Definitions.bn_eval_inj", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Exponentiation.bn_mod_exp_vartime_precompr2", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.Exponentiation.mk_bn_mod_exp_precompr2", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__exp_vt_precomp", "Hacl.Spec.Bignum.Montgomery.bn_precomp_r2_mod_n_lemma", "Prims.op_Subtraction", "FStar.Math.Lemmas.pow2_le_compat", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.bn_lt_mask_lemma", "Hacl.Bignum.bn_lt_mask", "Lib.Buffer.lbuffer_t", "Lib.Buffer.sub", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.pow2", "Prims.op_Multiply", "Hacl.Spec.Bignum.Definitions.blocks" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits
[]
Hacl.Impl.RSAPSS.rsapss_verify_bn
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_verify_bn_st t ke modBits
{ "end_col": 5, "end_line": 338, "start_col": 2, "start_line": 311 }
Prims.Tot
val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res
val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m =
false
null
false
push_frame (); [@@ inline_let ]let bits:size_pos = bits t in [@@ inline_let ]let numb:size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@@ inline_let ]let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.RSAPSS.Padding.pss_verify", "Hacl.Bignum.bn_to_bytes_be", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Prims._assert", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.l_and", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Hacl.Spec.Bignum.Definitions.blocks", "Hacl.Spec.RSAPSS.blocks_numb_lemma", "Hacl.Spec.RSAPSS.blocks_bits_lemma", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.create", "Lib.IntTypes.u8", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.IntTypes.op_Subtraction_Bang", "Prims.pos", "Lib.IntTypes.numbytes", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits
[]
Hacl.Impl.RSAPSS.rsapss_verify_bn_to_msg
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_verify_bn_to_msg_st t a modBits
{ "end_col": 5, "end_line": 384, "start_col": 2, "start_line": 364 }
Prims.Tot
val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b
val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m =
false
null
false
push_frame (); [@@ inline_let ]let bits:size_pos = bits t in [@@ inline_let ]let numb:size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.RSAPSS.rsapss_verify_bn", "Hacl.Bignum.bn_from_bytes_be", "Prims._assert", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.l_and", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Hacl.Spec.Bignum.Definitions.blocks", "Hacl.Spec.RSAPSS.blocks_numb_lemma", "Hacl.Spec.RSAPSS.blocks_bits_lemma", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.IntTypes.mk_int", "Prims.pos", "Lib.IntTypes.numbytes", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits
[]
Hacl.Impl.RSAPSS.rsapss_verify_compute_msg
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_verify_compute_msg_st t ke modBits
{ "end_col": 3, "end_line": 427, "start_col": 2, "start_line": 412 }
Prims.Tot
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s =
false
null
false
[@@ inline_let ]let bits:size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Base.unsafe_bool_of_limb", "Prims.bool", "Prims.unit", "Lib.Buffer.mapT", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.logand", "Lib.IntTypes.SEC", "Hacl.Bignum.bn_eq_mask", "Hacl.Spec.Bignum.Definitions.bn_eval_inj", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.Exponentiation.bn_mod_exp_vartime_precompr2", "Hacl.Spec.Bignum.Exponentiation.bn_mod_exp_consttime_precompr2", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.Exponentiation.mk_bn_mod_exp_precompr2", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__exp_vt_precomp", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__exp_ct_precomp", "Hacl.Spec.Bignum.Montgomery.bn_precomp_r2_mod_n_lemma", "Prims.op_Subtraction", "FStar.Math.Lemmas.pow2_le_compat", "FStar.Mul.op_Star", "Lib.Buffer.lbuffer_t", "Lib.Buffer.sub", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.pos" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
[]
Hacl.Impl.RSAPSS.rsapss_sign_bn
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_sign_bn_st t ke modBits
{ "end_col": 29, "end_line": 86, "start_col": 2, "start_line": 62 }
Prims.Tot
val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame ()
val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m =
false
null
false
push_frame (); [@@ inline_let ]let bits:size_pos = bits t in [@@ inline_let ]let numb:size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@@ inline_let ]let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame ()
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Buffer.update_sub_f", "Hacl.Bignum.Definitions.limb", "FStar.UInt32.__uint_to_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Spec.Bignum.bn_from_bytes_be", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.Sequence.lseq", "Hacl.Bignum.bn_from_bytes_be", "Lib.IntTypes.mk_int", "Lib.IntTypes.numbytes", "Lib.Buffer.sub", "Lib.Buffer.lbuffer_t", "FStar.HyperStack.ST.get", "Prims._assert", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.l_and", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Hacl.Spec.Bignum.Definitions.blocks", "Hacl.Spec.RSAPSS.blocks_numb_lemma", "Hacl.Spec.RSAPSS.blocks_bits_lemma", "Hacl.Impl.RSAPSS.Padding.pss_encode", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.create", "Lib.IntTypes.u8", "Prims.eq2", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.IntTypes.op_Subtraction_Bang", "Prims.pos", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits
[]
Hacl.Impl.RSAPSS.rsapss_sign_msg_to_bn
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_sign_msg_to_bn_st t a modBits
{ "end_col": 14, "end_line": 136, "start_col": 2, "start_line": 115 }
Prims.Tot
val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res
val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg =
false
null
false
push_frame (); [@@ inline_let ]let bits:size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.RSAPSS.rsapss_verify_bn_to_msg", "Hacl.Impl.RSAPSS.rsapss_verify_compute_msg", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.pos", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b inline_for_extraction noextract let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits
[]
Hacl.Impl.RSAPSS.rsapss_verify_
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_verify_st1 t ke a modBits
{ "end_col": 5, "end_line": 467, "start_col": 2, "start_line": 460 }
Prims.Tot
val rsapss_pkey_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_pkey:RK.rsapss_load_pkey_st t ke modBits -> rsapss_verify:rsapss_verify_st t ke a modBits -> rsapss_pkey_verify_st t ke a modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_pkey_verify #t ke a modBits rsapss_load_pkey rsapss_verify eBits nb eb saltLen sgntLen sgnt msgLen msg = push_frame (); [@inline_let] let bits = size (bits t) in let pkey = create (2ul *! blocks modBits bits +! blocks eBits bits) (uint #t 0) in let h0 = ST.get () in let b = rsapss_load_pkey eBits nb eb pkey in LS.rsapss_load_pkey_lemma #t (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb); let res = if b then rsapss_verify eBits pkey saltLen sgntLen sgnt msgLen msg else false in pop_frame (); let h1 = ST.get () in assert (res == LS.rsapss_pkey_verify #t a (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)); res
val rsapss_pkey_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_pkey:RK.rsapss_load_pkey_st t ke modBits -> rsapss_verify:rsapss_verify_st t ke a modBits -> rsapss_pkey_verify_st t ke a modBits let rsapss_pkey_verify #t ke a modBits rsapss_load_pkey rsapss_verify eBits nb eb saltLen sgntLen sgnt msgLen msg =
false
null
false
push_frame (); [@@ inline_let ]let bits = size (bits t) in let pkey = create (2ul *! blocks modBits bits +! blocks eBits bits) (uint #t 0) in let h0 = ST.get () in let b = rsapss_load_pkey eBits nb eb pkey in LS.rsapss_load_pkey_lemma #t (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb); let res = if b then rsapss_verify eBits pkey saltLen sgntLen sgnt msgLen msg else false in pop_frame (); let h1 = ST.get () in assert (res == LS.rsapss_pkey_verify #t a (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)); res
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Hacl.Impl.RSAPSS.Keys.rsapss_load_pkey_st", "Hacl.Impl.RSAPSS.rsapss_verify_st", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.blocks", "FStar.UInt32.__uint_to_t", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.bool", "Hacl.Spec.RSAPSS.rsapss_pkey_verify", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.pop_frame", "Hacl.Spec.RSAPSS.rsapss_load_pkey_lemma", "Lib.Buffer.lbuffer_t", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.add", "Lib.IntTypes.mul", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.IntTypes.int_t", "Lib.IntTypes.size", "Lib.IntTypes.bits", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b inline_for_extraction noextract let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res inline_for_extraction noextract let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); assert (v msgLen <= max_size_t); assert (v hLen + 8 < max_size_t); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && sgntLen =. blocks modBits 8ul in if b then rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg else false inline_for_extraction noextract let rsapss_skey_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) = eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> nb:lbuffer uint8 (blocks modBits 8ul) -> eb:lbuffer uint8 (blocks eBits 8ul) -> db:lbuffer uint8 (blocks dBits 8ul) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ live h db /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint sgnt db /\ disjoint salt msg) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (let sgnt_s = S.rsapss_skey_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) in if b then Some? sgnt_s /\ as_seq h1 sgnt == Some?.v sgnt_s else None? sgnt_s)) inline_for_extraction noextract val rsapss_skey_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits -> rsapss_sign:rsapss_sign_st t ke a modBits -> rsapss_skey_sign_st t ke a modBits let rsapss_skey_sign #t ke a modBits rsapss_load_skey rsapss_sign eBits dBits nb eb db saltLen salt msgLen msg sgnt = [@inline_let] let bits = size (bits t) in let h0 = ST.get () in push_frame (); let skey = create (2ul *! blocks modBits bits +! blocks eBits bits +! blocks dBits bits) (uint #t 0) in let b = rsapss_load_skey eBits dBits nb eb db skey in LS.rsapss_load_skey_lemma #t (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db); let res = if b then rsapss_sign eBits dBits skey saltLen salt msgLen msg sgnt else false in pop_frame (); let h1 = ST.get () in assert ((res, as_seq h1 sgnt) == LS.rsapss_skey_sign #t a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)); res inline_for_extraction noextract let rsapss_pkey_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) = eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> nb:lbuffer uint8 (blocks modBits 8ul) -> eb:lbuffer uint8 (blocks eBits 8ul) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ disjoint msg sgnt /\ disjoint nb eb /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint msg nb /\ disjoint msg eb) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.rsapss_pkey_verify a (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_pkey_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_pkey:RK.rsapss_load_pkey_st t ke modBits -> rsapss_verify:rsapss_verify_st t ke a modBits -> rsapss_pkey_verify_st t ke a modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_pkey_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_pkey:RK.rsapss_load_pkey_st t ke modBits -> rsapss_verify:rsapss_verify_st t ke a modBits -> rsapss_pkey_verify_st t ke a modBits
[]
Hacl.Impl.RSAPSS.rsapss_pkey_verify
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> rsapss_load_pkey: Hacl.Impl.RSAPSS.Keys.rsapss_load_pkey_st t ke modBits -> rsapss_verify: Hacl.Impl.RSAPSS.rsapss_verify_st t ke a modBits -> Hacl.Impl.RSAPSS.rsapss_pkey_verify_st t ke a modBits
{ "end_col": 5, "end_line": 622, "start_col": 2, "start_line": 606 }
Prims.Tot
val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b
val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt =
false
null
false
push_frame (); let h_init = ST.get () in [@@ inline_let ]let bits:size_pos = bits t in [@@ inline_let ]let numb:size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Bignum.bn_to_bytes_be", "Prims._assert", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.l_and", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Hacl.Spec.Bignum.Definitions.blocks", "Hacl.Spec.RSAPSS.blocks_numb_lemma", "Hacl.Spec.RSAPSS.blocks_bits_lemma", "Hacl.Impl.RSAPSS.rsapss_sign_bn", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.IntTypes.mk_int", "Prims.pos", "Lib.IntTypes.numbytes", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits
[]
Hacl.Impl.RSAPSS.rsapss_sign_compute_sgnt
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_sign_compute_sgnt_st t ke modBits
{ "end_col": 6, "end_line": 181, "start_col": 2, "start_line": 165 }
Prims.Tot
val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b
val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
false
null
false
push_frame (); [@@ inline_let ]let bits:size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.RSAPSS.rsapss_sign_compute_sgnt", "Hacl.Impl.RSAPSS.rsapss_sign_msg_to_bn", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.pos", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits
[]
Hacl.Impl.RSAPSS.rsapss_sign_
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_sign_st1 t ke a modBits
{ "end_col": 6, "end_line": 224, "start_col": 2, "start_line": 217 }
Prims.Tot
val rsapss_skey_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits -> rsapss_sign:rsapss_sign_st t ke a modBits -> rsapss_skey_sign_st t ke a modBits
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rsapss_skey_sign #t ke a modBits rsapss_load_skey rsapss_sign eBits dBits nb eb db saltLen salt msgLen msg sgnt = [@inline_let] let bits = size (bits t) in let h0 = ST.get () in push_frame (); let skey = create (2ul *! blocks modBits bits +! blocks eBits bits +! blocks dBits bits) (uint #t 0) in let b = rsapss_load_skey eBits dBits nb eb db skey in LS.rsapss_load_skey_lemma #t (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db); let res = if b then rsapss_sign eBits dBits skey saltLen salt msgLen msg sgnt else false in pop_frame (); let h1 = ST.get () in assert ((res, as_seq h1 sgnt) == LS.rsapss_skey_sign #t a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)); res
val rsapss_skey_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits -> rsapss_sign:rsapss_sign_st t ke a modBits -> rsapss_skey_sign_st t ke a modBits let rsapss_skey_sign #t ke a modBits rsapss_load_skey rsapss_sign eBits dBits nb eb db saltLen salt msgLen msg sgnt =
false
null
false
[@@ inline_let ]let bits = size (bits t) in let h0 = ST.get () in push_frame (); let skey = create (2ul *! blocks modBits bits +! blocks eBits bits +! blocks dBits bits) (uint #t 0) in let b = rsapss_load_skey eBits dBits nb eb db skey in LS.rsapss_load_skey_lemma #t (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db); let res = if b then rsapss_sign eBits dBits skey saltLen salt msgLen msg sgnt else false in pop_frame (); let h1 = ST.get () in assert ((res, as_seq h1 sgnt) == LS.rsapss_skey_sign #t a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)); res
{ "checked_file": "Hacl.Impl.RSAPSS.fst.checked", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Hacl.Impl.RSAPSS.Keys.rsapss_load_skey_st", "Hacl.Impl.RSAPSS.rsapss_sign_st", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.blocks", "FStar.UInt32.__uint_to_t", "Prims.unit", "Prims._assert", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "Prims.bool", "Lib.Sequence.lseq", "Hacl.Spec.Bignum.Definitions.blocks", "FStar.Pervasives.Native.Mktuple2", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Spec.RSAPSS.rsapss_skey_sign", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.pop_frame", "Hacl.Spec.RSAPSS.rsapss_load_skey_lemma", "Lib.Buffer.lbuffer_t", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.add", "Lib.IntTypes.mul", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "FStar.HyperStack.ST.push_frame", "Lib.IntTypes.int_t", "Lib.IntTypes.size", "Lib.IntTypes.bits" ]
[]
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b inline_for_extraction noextract let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res inline_for_extraction noextract let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); assert (v msgLen <= max_size_t); assert (v hLen + 8 < max_size_t); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && sgntLen =. blocks modBits 8ul in if b then rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg else false inline_for_extraction noextract let rsapss_skey_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) = eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> nb:lbuffer uint8 (blocks modBits 8ul) -> eb:lbuffer uint8 (blocks eBits 8ul) -> db:lbuffer uint8 (blocks dBits 8ul) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ live h db /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint sgnt db /\ disjoint salt msg) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (let sgnt_s = S.rsapss_skey_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) in if b then Some? sgnt_s /\ as_seq h1 sgnt == Some?.v sgnt_s else None? sgnt_s)) inline_for_extraction noextract val rsapss_skey_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits -> rsapss_sign:rsapss_sign_st t ke a modBits -> rsapss_skey_sign_st t ke a modBits
false
false
Hacl.Impl.RSAPSS.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": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rsapss_skey_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits -> rsapss_sign:rsapss_sign_st t ke a modBits -> rsapss_skey_sign_st t ke a modBits
[]
Hacl.Impl.RSAPSS.rsapss_skey_sign
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> rsapss_load_skey: Hacl.Impl.RSAPSS.Keys.rsapss_load_skey_st t ke modBits -> rsapss_sign: Hacl.Impl.RSAPSS.rsapss_sign_st t ke a modBits -> Hacl.Impl.RSAPSS.rsapss_skey_sign_st t ke a modBits
{ "end_col": 5, "end_line": 571, "start_col": 2, "start_line": 554 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_k_w_256 = 64
let size_k_w_256 =
false
null
false
64
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0"
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_k_w_256 : Prims.int
[]
Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 28, "end_line": 20, "start_col": 26, "start_line": 20 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sigma_0_1_partial = opaque_make sigma_0_1_partial_def
let sigma_0_1_partial =
false
null
false
opaque_make sigma_0_1_partial_def
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.SHA.PPC64LE.SHA_helpers.counter", "Vale.SHA.PPC64LE.SHA_helpers.block_w", "Vale.Def.Words_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial_def" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sigma_0_1_partial : _: Vale.SHA.PPC64LE.SHA_helpers.counter -> _: Vale.SHA.PPC64LE.SHA_helpers.block_w -> Vale.Def.Words_s.nat32
[]
Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Vale.SHA.PPC64LE.SHA_helpers.counter -> _: Vale.SHA.PPC64LE.SHA_helpers.block_w -> Vale.Def.Words_s.nat32
{ "end_col": 76, "end_line": 86, "start_col": 43, "start_line": 86 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_block_w_256 = 16
let size_block_w_256 =
false
null
false
16
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_block_w_256 : Prims.int
[]
Vale.SHA.PPC64LE.SHA_helpers.size_block_w_256
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 25, "end_line": 23, "start_col": 23, "start_line": 23 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let hash256 = m:Seq.seq word {Seq.length m = 8}
let hash256 =
false
null
false
m: Seq.seq word {Seq.length m = 8}
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Vale.SHA.PPC64LE.SHA_helpers.word", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hash256 : Type0
[]
Vale.SHA.PPC64LE.SHA_helpers.hash256
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 47, "end_line": 30, "start_col": 14, "start_line": 30 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let block_length = 4 (*word_length a*) * size_block_w_256
let block_length =
false
null
false
4 * size_block_w_256
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "FStar.Mul.op_Star", "Vale.SHA.PPC64LE.SHA_helpers.size_block_w_256" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *)
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val block_length : Prims.int
[]
Vale.SHA.PPC64LE.SHA_helpers.block_length
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 40, "end_line": 26, "start_col": 2, "start_line": 26 }
FStar.Pervasives.Lemma
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def
let sigma_0_1_partial_reveal =
false
null
true
opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "lemma" ]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.SHA.PPC64LE.SHA_helpers.counter", "Vale.SHA.PPC64LE.SHA_helpers.block_w", "Vale.Def.Words_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial", "Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial_def" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32
false
false
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sigma_0_1_partial_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial == Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial_def)
[]
Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial_reveal
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial == Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial_def)
{ "end_col": 120, "end_line": 87, "start_col": 43, "start_line": 87 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sigma_0_0_partial = opaque_make sigma_0_0_partial_def
let sigma_0_0_partial =
false
null
false
opaque_make sigma_0_0_partial_def
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.SHA.PPC64LE.SHA_helpers.counter", "Vale.SHA.PPC64LE.SHA_helpers.block_w", "Vale.Def.Words_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial_def" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sigma_0_0_partial : _: Vale.SHA.PPC64LE.SHA_helpers.counter -> _: Vale.SHA.PPC64LE.SHA_helpers.block_w -> Vale.Def.Words_s.nat32
[]
Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Vale.SHA.PPC64LE.SHA_helpers.counter -> _: Vale.SHA.PPC64LE.SHA_helpers.block_w -> Vale.Def.Words_s.nat32
{ "end_col": 76, "end_line": 77, "start_col": 43, "start_line": 77 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sigma_1_1_partial = opaque_make sigma_1_1_partial_def
let sigma_1_1_partial =
false
null
false
opaque_make sigma_1_1_partial_def
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.SHA.PPC64LE.SHA_helpers.counter", "Vale.SHA.PPC64LE.SHA_helpers.block_w", "Vale.SHA.PPC64LE.SHA_helpers.hash256", "Vale.Def.Words_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial_def" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block)) val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) (ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sigma_1_1_partial : _: Vale.SHA.PPC64LE.SHA_helpers.counter -> _: Vale.SHA.PPC64LE.SHA_helpers.block_w -> _: Vale.SHA.PPC64LE.SHA_helpers.hash256 -> Vale.Def.Words_s.nat32
[]
Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Vale.SHA.PPC64LE.SHA_helpers.counter -> _: Vale.SHA.PPC64LE.SHA_helpers.block_w -> _: Vale.SHA.PPC64LE.SHA_helpers.hash256 -> Vale.Def.Words_s.nat32
{ "end_col": 76, "end_line": 104, "start_col": 43, "start_line": 104 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let block_w = m:seq word {length m = size_block_w_256}
let block_w =
false
null
false
m: seq word {length m = size_block_w_256}
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Vale.SHA.PPC64LE.SHA_helpers.word", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "Vale.SHA.PPC64LE.SHA_helpers.size_block_w_256" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length =
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val block_w : Type0
[]
Vale.SHA.PPC64LE.SHA_helpers.block_w
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 55, "end_line": 27, "start_col": 15, "start_line": 27 }
FStar.Pervasives.Lemma
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def
let sigma_1_0_partial_reveal =
false
null
true
opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "lemma" ]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.SHA.PPC64LE.SHA_helpers.counter", "Vale.SHA.PPC64LE.SHA_helpers.block_w", "Vale.SHA.PPC64LE.SHA_helpers.hash256", "Vale.Def.Words_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.sigma_1_0_partial", "Vale.SHA.PPC64LE.SHA_helpers.sigma_1_0_partial_def" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block)) val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32
false
false
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sigma_1_0_partial_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.SHA.PPC64LE.SHA_helpers.sigma_1_0_partial == Vale.SHA.PPC64LE.SHA_helpers.sigma_1_0_partial_def)
[]
Vale.SHA.PPC64LE.SHA_helpers.sigma_1_0_partial_reveal
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.SHA.PPC64LE.SHA_helpers.sigma_1_0_partial == Vale.SHA.PPC64LE.SHA_helpers.sigma_1_0_partial_def)
{ "end_col": 120, "end_line": 96, "start_col": 43, "start_line": 96 }
FStar.Pervasives.Lemma
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sigma_1_1_partial_reveal = opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def
let sigma_1_1_partial_reveal =
false
null
true
opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "lemma" ]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.SHA.PPC64LE.SHA_helpers.counter", "Vale.SHA.PPC64LE.SHA_helpers.block_w", "Vale.SHA.PPC64LE.SHA_helpers.hash256", "Vale.Def.Words_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial", "Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial_def" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block)) val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) (ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig)) val sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32
false
false
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sigma_1_1_partial_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial == Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial_def)
[]
Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial_reveal
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial == Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial_def)
{ "end_col": 120, "end_line": 105, "start_col": 43, "start_line": 105 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let counter = nat
let counter =
false
null
false
nat
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "Prims.nat" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val counter : Type0
[]
Vale.SHA.PPC64LE.SHA_helpers.counter
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 17, "end_line": 28, "start_col": 14, "start_line": 28 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sigma_1_0_partial = opaque_make sigma_1_0_partial_def
let sigma_1_0_partial =
false
null
false
opaque_make sigma_1_0_partial_def
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.SHA.PPC64LE.SHA_helpers.counter", "Vale.SHA.PPC64LE.SHA_helpers.block_w", "Vale.SHA.PPC64LE.SHA_helpers.hash256", "Vale.Def.Words_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.sigma_1_0_partial_def" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sigma_1_0_partial : _: Vale.SHA.PPC64LE.SHA_helpers.counter -> _: Vale.SHA.PPC64LE.SHA_helpers.block_w -> _: Vale.SHA.PPC64LE.SHA_helpers.hash256 -> Vale.Def.Words_s.nat32
[]
Vale.SHA.PPC64LE.SHA_helpers.sigma_1_0_partial
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Vale.SHA.PPC64LE.SHA_helpers.counter -> _: Vale.SHA.PPC64LE.SHA_helpers.block_w -> _: Vale.SHA.PPC64LE.SHA_helpers.hash256 -> Vale.Def.Words_s.nat32
{ "end_col": 76, "end_line": 95, "start_col": 43, "start_line": 95 }
FStar.Pervasives.Lemma
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def
let sigma_0_0_partial_reveal =
false
null
true
opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "lemma" ]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.SHA.PPC64LE.SHA_helpers.counter", "Vale.SHA.PPC64LE.SHA_helpers.block_w", "Vale.Def.Words_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial", "Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial_def" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32
false
false
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sigma_0_0_partial_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial == Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial_def)
[]
Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial_reveal
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial == Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial_def)
{ "end_col": 120, "end_line": 78, "start_col": 43, "start_line": 78 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let repeat_range_vale_64 (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash
let repeat_range_vale_64 (block: block_w) (hash: hash256) =
false
null
false
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "Vale.SHA.PPC64LE.SHA_helpers.block_w", "Vale.SHA.PPC64LE.SHA_helpers.hash256", "Spec.Loops.repeat_range", "Vale.SHA.PPC64LE.SHA_helpers.shuffle_core_opaque" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block)) val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) (ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig)) val sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_1_partial = opaque_make sigma_1_1_partial_def irreducible let sigma_1_1_partial_reveal = opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def val lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) (ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig)) val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a /\ hash.[1] == nat32_to_word b /\ hash.[2] == nat32_to_word c /\ hash.[3] == nat32_to_word d /\ hash.[4] == nat32_to_word e /\ hash.[5] == nat32_to_word f /\ hash.[6] == nat32_to_word g /\ hash.[7] == nat32_to_word h ) val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a.hi3 /\ hash.[1] == nat32_to_word b.hi3 /\ hash.[2] == nat32_to_word c.hi3 /\ hash.[3] == nat32_to_word d.hi3 /\ hash.[4] == nat32_to_word e.hi3 /\ hash.[5] == nat32_to_word f.hi3 /\ hash.[6] == nat32_to_word g.hi3 /\ hash.[7] == nat32_to_word h.hi3 ) val lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma (requires length hash == 8 /\ a.hi3 == word_to_nat32 hash.[0] /\ b.hi3 == word_to_nat32 hash.[1] /\ c.hi3 == word_to_nat32 hash.[2] /\ d.hi3 == word_to_nat32 hash.[3] /\ e.hi3 == word_to_nat32 hash.[4] /\ f.hi3 == word_to_nat32 hash.[5] /\ g.hi3 == word_to_nat32 hash.[6] /\ h.hi3 == word_to_nat32 hash.[7]) (ensures hash == make_seperated_hash_quad32 a b c d e f g h) val lemma_vsel32 (a b c:nat32) : Lemma (ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b))) val ch_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ (iand32 (inot32 x) z)) val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma (ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))) val maj_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))) val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block)) val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block)) val lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig)) val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig)) (* Abbreviations and lemmas for the code itself *) let k_reqs (k_seq:seq quad32) : prop0 = length k_seq == size_k_w_256 / 4 /\ (forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==> (k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\ (k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\ (k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\ (k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3])) let quads_to_block_be (qs:seq quad32) : block_w = let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_BE qs in let f (n:nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[n] else 0) in init 16 f val lemma_quads_to_block_be (qs:seq quad32) : Lemma (requires length qs == 4) (ensures (let block = quads_to_block_be qs in forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==> (qs.[i]).hi3 == ws_opaque block (4 * i + 0) /\ (qs.[i]).hi2 == ws_opaque block (4 * i + 1) /\ (qs.[i]).lo1 == ws_opaque block (4 * i + 2) /\ (qs.[i]).lo0 == ws_opaque block (4 * i + 3))) let k_index (ks:seq quad32) (i:nat) : nat32 = if length ks = size_k_w_256 / 4 && i < size_k_w_256 then four_select ks.[(i/4)] (i % 4) else 0 val lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in let a0 = word_to_nat32 hash.[0] in let b0 = word_to_nat32 hash.[1] in let c0 = word_to_nat32 hash.[2] in let d0 = word_to_nat32 hash.[3] in let e0 = word_to_nat32 hash.[4] in let f0 = word_to_nat32 hash.[5] in let g0 = word_to_nat32 hash.[6] in let h0 = word_to_nat32 hash.[7] in let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in word_to_nat32 h.[0] == add_wrap t1 t2 /\ word_to_nat32 h.[1] == a0 /\ word_to_nat32 h.[2] == b0 /\ word_to_nat32 h.[3] == c0 /\ word_to_nat32 h.[4] == add_wrap d0 t1 /\ word_to_nat32 h.[5] == e0 /\ word_to_nat32 h.[6] == f0 /\ word_to_nat32 h.[7] == g0)) val lemma_ws_opaque (block:block_w) (t:counter) : Lemma (requires 16 <= t && t < size_k_w_256) (ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16))))
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeat_range_vale_64 : block: Vale.SHA.PPC64LE.SHA_helpers.block_w -> hash: Vale.SHA.PPC64LE.SHA_helpers.hash256 -> Vale.SHA.PPC64LE.SHA_helpers.hash256
[]
Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale_64
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
block: Vale.SHA.PPC64LE.SHA_helpers.block_w -> hash: Vale.SHA.PPC64LE.SHA_helpers.hash256 -> Vale.SHA.PPC64LE.SHA_helpers.hash256
{ "end_col": 63, "end_line": 242, "start_col": 2, "start_line": 242 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bytes_blocks = l:bytes { Seq.length l % block_length = 0 }
let bytes_blocks =
false
null
false
l: bytes{Seq.length l % block_length = 0}
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "Vale.SHA.PPC64LE.SHA_helpers.bytes", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Vale.SHA.PPC64LE.SHA_helpers.byte", "Vale.SHA.PPC64LE.SHA_helpers.block_length" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *)
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bytes_blocks : Type0
[]
Vale.SHA.PPC64LE.SHA_helpers.bytes_blocks
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 45, "end_line": 38, "start_col": 2, "start_line": 38 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
let repeat_range_vale (max: nat{max < size_k_w_256}) (block: block_w) (hash: hash256) =
false
null
false
Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256", "Vale.SHA.PPC64LE.SHA_helpers.block_w", "Vale.SHA.PPC64LE.SHA_helpers.hash256", "Spec.Loops.repeat_range", "Vale.SHA.PPC64LE.SHA_helpers.shuffle_core_opaque" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256
false
false
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeat_range_vale : max: Prims.nat{max < Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256} -> block: Vale.SHA.PPC64LE.SHA_helpers.block_w -> hash: Vale.SHA.PPC64LE.SHA_helpers.hash256 -> Vale.SHA.PPC64LE.SHA_helpers.hash256
[]
Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
max: Prims.nat{max < Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256} -> block: Vale.SHA.PPC64LE.SHA_helpers.block_w -> hash: Vale.SHA.PPC64LE.SHA_helpers.hash256 -> Vale.SHA.PPC64LE.SHA_helpers.hash256
{ "end_col": 64, "end_line": 52, "start_col": 2, "start_line": 52 }
Prims.Tot
val update_multi_opaque_vale (hash: hash256) (blocks: bytes) : hash256
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
val update_multi_opaque_vale (hash: hash256) (blocks: bytes) : hash256 let update_multi_opaque_vale (hash: hash256) (blocks: bytes) : hash256 =
false
null
false
if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "Vale.SHA.PPC64LE.SHA_helpers.hash256", "Vale.SHA.PPC64LE.SHA_helpers.bytes", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Vale.SHA.PPC64LE.SHA_helpers.byte", "Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256", "Vale.SHA.PPC64LE.SHA_helpers.update_multi_opaque", "Vale.SHA.PPC64LE.SHA_helpers.bytes_blocks", "Prims.bool" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_multi_opaque_vale (hash: hash256) (blocks: bytes) : hash256
[]
Vale.SHA.PPC64LE.SHA_helpers.update_multi_opaque_vale
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hash: Vale.SHA.PPC64LE.SHA_helpers.hash256 -> blocks: Vale.SHA.PPC64LE.SHA_helpers.bytes -> Vale.SHA.PPC64LE.SHA_helpers.hash256
{ "end_col": 110, "end_line": 54, "start_col": 2, "start_line": 54 }
Prims.Tot
val le_bytes_to_hash (b: seq nat8) : hash256
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_bytes_to_hash (b:seq nat8) : hash256 = if length b <> 32 then (let f (n:nat{n < 8}) : word = nat32_to_word 0 in init 8 f) else ( let open Vale.Def.Words.Seq_s in Vale.Lib.Seqs_s.seq_map nat32_to_word (seq_nat8_to_seq_nat32_LE b) )
val le_bytes_to_hash (b: seq nat8) : hash256 let le_bytes_to_hash (b: seq nat8) : hash256 =
false
null
false
if length b <> 32 then (let f (n: nat{n < 8}) : word = nat32_to_word 0 in init 8 f) else (let open Vale.Def.Words.Seq_s in Vale.Lib.Seqs_s.seq_map nat32_to_word (seq_nat8_to_seq_nat32_LE b))
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat8", "Prims.op_disEquality", "Prims.int", "FStar.Seq.Base.length", "FStar.Seq.Base.init", "Vale.SHA.PPC64LE.SHA_helpers.word", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Vale.SHA.PPC64LE.SHA_helpers.nat32_to_word", "Prims.bool", "Vale.Lib.Seqs_s.seq_map", "Vale.Def.Words_s.nat32", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE", "Vale.SHA.PPC64LE.SHA_helpers.hash256" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block)) val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) (ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig)) val sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_1_partial = opaque_make sigma_1_1_partial_def irreducible let sigma_1_1_partial_reveal = opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def val lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) (ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig)) val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a /\ hash.[1] == nat32_to_word b /\ hash.[2] == nat32_to_word c /\ hash.[3] == nat32_to_word d /\ hash.[4] == nat32_to_word e /\ hash.[5] == nat32_to_word f /\ hash.[6] == nat32_to_word g /\ hash.[7] == nat32_to_word h ) val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a.hi3 /\ hash.[1] == nat32_to_word b.hi3 /\ hash.[2] == nat32_to_word c.hi3 /\ hash.[3] == nat32_to_word d.hi3 /\ hash.[4] == nat32_to_word e.hi3 /\ hash.[5] == nat32_to_word f.hi3 /\ hash.[6] == nat32_to_word g.hi3 /\ hash.[7] == nat32_to_word h.hi3 ) val lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma (requires length hash == 8 /\ a.hi3 == word_to_nat32 hash.[0] /\ b.hi3 == word_to_nat32 hash.[1] /\ c.hi3 == word_to_nat32 hash.[2] /\ d.hi3 == word_to_nat32 hash.[3] /\ e.hi3 == word_to_nat32 hash.[4] /\ f.hi3 == word_to_nat32 hash.[5] /\ g.hi3 == word_to_nat32 hash.[6] /\ h.hi3 == word_to_nat32 hash.[7]) (ensures hash == make_seperated_hash_quad32 a b c d e f g h) val lemma_vsel32 (a b c:nat32) : Lemma (ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b))) val ch_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ (iand32 (inot32 x) z)) val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma (ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))) val maj_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))) val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block)) val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block)) val lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig)) val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig)) (* Abbreviations and lemmas for the code itself *) let k_reqs (k_seq:seq quad32) : prop0 = length k_seq == size_k_w_256 / 4 /\ (forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==> (k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\ (k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\ (k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\ (k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3])) let quads_to_block_be (qs:seq quad32) : block_w = let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_BE qs in let f (n:nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[n] else 0) in init 16 f val lemma_quads_to_block_be (qs:seq quad32) : Lemma (requires length qs == 4) (ensures (let block = quads_to_block_be qs in forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==> (qs.[i]).hi3 == ws_opaque block (4 * i + 0) /\ (qs.[i]).hi2 == ws_opaque block (4 * i + 1) /\ (qs.[i]).lo1 == ws_opaque block (4 * i + 2) /\ (qs.[i]).lo0 == ws_opaque block (4 * i + 3))) let k_index (ks:seq quad32) (i:nat) : nat32 = if length ks = size_k_w_256 / 4 && i < size_k_w_256 then four_select ks.[(i/4)] (i % 4) else 0 val lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in let a0 = word_to_nat32 hash.[0] in let b0 = word_to_nat32 hash.[1] in let c0 = word_to_nat32 hash.[2] in let d0 = word_to_nat32 hash.[3] in let e0 = word_to_nat32 hash.[4] in let f0 = word_to_nat32 hash.[5] in let g0 = word_to_nat32 hash.[6] in let h0 = word_to_nat32 hash.[7] in let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in word_to_nat32 h.[0] == add_wrap t1 t2 /\ word_to_nat32 h.[1] == a0 /\ word_to_nat32 h.[2] == b0 /\ word_to_nat32 h.[3] == c0 /\ word_to_nat32 h.[4] == add_wrap d0 t1 /\ word_to_nat32 h.[5] == e0 /\ word_to_nat32 h.[6] == f0 /\ word_to_nat32 h.[7] == g0)) val lemma_ws_opaque (block:block_w) (t:counter) : Lemma (requires 16 <= t && t < size_k_w_256) (ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16)))) let repeat_range_vale_64 (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash val update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma (requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in make_seperated_hash_quad32 a b c d e f g h == repeat_range_vale_64 block hash_orig /\ a' == add_wrap_quad32 a a_old /\ b' == add_wrap_quad32 b b_old /\ c' == add_wrap_quad32 c c_old /\ d' == add_wrap_quad32 d d_old /\ e' == add_wrap_quad32 e e_old /\ f' == add_wrap_quad32 f f_old /\ g' == add_wrap_quad32 g g_old /\ h' == add_wrap_quad32 h h_old)) (ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block)) let rec update_multi_quads (s:seq quad32) (hash_orig:hash256) : Tot (hash256) (decreases (length s)) = if length s < 4 then hash_orig else let prefix, qs = split s (length s - 4) in let h_prefix = update_multi_quads prefix hash_orig in let hash = update_block h_prefix (quads_to_block_be qs) in hash val lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma (requires bound + 4 <= length s) (ensures (let prefix_LE = slice s 0 bound in let prefix_BE = reverse_bytes_quad32_seq prefix_LE in let h_prefix = update_multi_quads prefix_BE hash_orig in let block_quads_LE = slice s bound (bound + 4) in let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in let input_LE = slice s 0 (bound+4) in let input_BE = reverse_bytes_quad32_seq input_LE in let h = update_block h_prefix (quads_to_block_be block_quads_BE) in h == update_multi_quads input_BE hash_orig))
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_bytes_to_hash (b: seq nat8) : hash256
[]
Vale.SHA.PPC64LE.SHA_helpers.le_bytes_to_hash
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 -> Vale.SHA.PPC64LE.SHA_helpers.hash256
{ "end_col": 3, "end_line": 288, "start_col": 2, "start_line": 282 }
Prims.Tot
val k_index (ks: seq quad32) (i: nat) : nat32
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let k_index (ks:seq quad32) (i:nat) : nat32 = if length ks = size_k_w_256 / 4 && i < size_k_w_256 then four_select ks.[(i/4)] (i % 4) else 0
val k_index (ks: seq quad32) (i: nat) : nat32 let k_index (ks: seq quad32) (i: nat) : nat32 =
false
null
false
if length ks = size_k_w_256 / 4 && i < size_k_w_256 then four_select ks.[ (i / 4) ] (i % 4) else 0
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.op_AmpAmp", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "Prims.op_Division", "Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256", "Prims.op_LessThan", "Vale.Def.Words.Four_s.four_select", "Vale.Def.Types_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.op_String_Access", "Prims.op_Modulus", "Prims.bool", "Vale.Def.Words_s.nat32" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block)) val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) (ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig)) val sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_1_partial = opaque_make sigma_1_1_partial_def irreducible let sigma_1_1_partial_reveal = opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def val lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) (ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig)) val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a /\ hash.[1] == nat32_to_word b /\ hash.[2] == nat32_to_word c /\ hash.[3] == nat32_to_word d /\ hash.[4] == nat32_to_word e /\ hash.[5] == nat32_to_word f /\ hash.[6] == nat32_to_word g /\ hash.[7] == nat32_to_word h ) val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a.hi3 /\ hash.[1] == nat32_to_word b.hi3 /\ hash.[2] == nat32_to_word c.hi3 /\ hash.[3] == nat32_to_word d.hi3 /\ hash.[4] == nat32_to_word e.hi3 /\ hash.[5] == nat32_to_word f.hi3 /\ hash.[6] == nat32_to_word g.hi3 /\ hash.[7] == nat32_to_word h.hi3 ) val lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma (requires length hash == 8 /\ a.hi3 == word_to_nat32 hash.[0] /\ b.hi3 == word_to_nat32 hash.[1] /\ c.hi3 == word_to_nat32 hash.[2] /\ d.hi3 == word_to_nat32 hash.[3] /\ e.hi3 == word_to_nat32 hash.[4] /\ f.hi3 == word_to_nat32 hash.[5] /\ g.hi3 == word_to_nat32 hash.[6] /\ h.hi3 == word_to_nat32 hash.[7]) (ensures hash == make_seperated_hash_quad32 a b c d e f g h) val lemma_vsel32 (a b c:nat32) : Lemma (ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b))) val ch_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ (iand32 (inot32 x) z)) val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma (ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))) val maj_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))) val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block)) val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block)) val lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig)) val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig)) (* Abbreviations and lemmas for the code itself *) let k_reqs (k_seq:seq quad32) : prop0 = length k_seq == size_k_w_256 / 4 /\ (forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==> (k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\ (k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\ (k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\ (k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3])) let quads_to_block_be (qs:seq quad32) : block_w = let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_BE qs in let f (n:nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[n] else 0) in init 16 f val lemma_quads_to_block_be (qs:seq quad32) : Lemma (requires length qs == 4) (ensures (let block = quads_to_block_be qs in forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==> (qs.[i]).hi3 == ws_opaque block (4 * i + 0) /\ (qs.[i]).hi2 == ws_opaque block (4 * i + 1) /\ (qs.[i]).lo1 == ws_opaque block (4 * i + 2) /\ (qs.[i]).lo0 == ws_opaque block (4 * i + 3)))
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val k_index (ks: seq quad32) (i: nat) : nat32
[]
Vale.SHA.PPC64LE.SHA_helpers.k_index
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ks: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> i: Prims.nat -> Vale.Def.Words_s.nat32
{ "end_col": 8, "end_line": 209, "start_col": 2, "start_line": 208 }
Prims.Tot
val quads_to_block_be (qs: seq quad32) : block_w
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let quads_to_block_be (qs:seq quad32) : block_w = let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_BE qs in let f (n:nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[n] else 0) in init 16 f
val quads_to_block_be (qs: seq quad32) : block_w let quads_to_block_be (qs: seq quad32) : block_w =
false
null
false
let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_BE qs in let f (n: nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[ n ] else 0) in init 16 f
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.init", "Vale.SHA.PPC64LE.SHA_helpers.word", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Vale.SHA.PPC64LE.SHA_helpers.nat32_to_word", "FStar.Seq.Base.length", "Vale.Def.Types_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.op_String_Access", "Prims.bool", "Vale.Def.Words_s.nat32", "Prims.eq2", "Prims.int", "Prims.op_Multiply", "Vale.Def.Words_s.four", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.SHA.PPC64LE.SHA_helpers.block_w" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block)) val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) (ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig)) val sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_1_partial = opaque_make sigma_1_1_partial_def irreducible let sigma_1_1_partial_reveal = opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def val lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) (ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig)) val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a /\ hash.[1] == nat32_to_word b /\ hash.[2] == nat32_to_word c /\ hash.[3] == nat32_to_word d /\ hash.[4] == nat32_to_word e /\ hash.[5] == nat32_to_word f /\ hash.[6] == nat32_to_word g /\ hash.[7] == nat32_to_word h ) val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a.hi3 /\ hash.[1] == nat32_to_word b.hi3 /\ hash.[2] == nat32_to_word c.hi3 /\ hash.[3] == nat32_to_word d.hi3 /\ hash.[4] == nat32_to_word e.hi3 /\ hash.[5] == nat32_to_word f.hi3 /\ hash.[6] == nat32_to_word g.hi3 /\ hash.[7] == nat32_to_word h.hi3 ) val lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma (requires length hash == 8 /\ a.hi3 == word_to_nat32 hash.[0] /\ b.hi3 == word_to_nat32 hash.[1] /\ c.hi3 == word_to_nat32 hash.[2] /\ d.hi3 == word_to_nat32 hash.[3] /\ e.hi3 == word_to_nat32 hash.[4] /\ f.hi3 == word_to_nat32 hash.[5] /\ g.hi3 == word_to_nat32 hash.[6] /\ h.hi3 == word_to_nat32 hash.[7]) (ensures hash == make_seperated_hash_quad32 a b c d e f g h) val lemma_vsel32 (a b c:nat32) : Lemma (ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b))) val ch_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ (iand32 (inot32 x) z)) val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma (ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))) val maj_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))) val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block)) val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block)) val lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig)) val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig)) (* Abbreviations and lemmas for the code itself *) let k_reqs (k_seq:seq quad32) : prop0 = length k_seq == size_k_w_256 / 4 /\ (forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==> (k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\ (k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\ (k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\ (k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3]))
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val quads_to_block_be (qs: seq quad32) : block_w
[]
Vale.SHA.PPC64LE.SHA_helpers.quads_to_block_be
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
qs: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> Vale.SHA.PPC64LE.SHA_helpers.block_w
{ "end_col": 11, "end_line": 195, "start_col": 3, "start_line": 192 }
Prims.Tot
val update_multi_quads (s: seq quad32) (hash_orig: hash256) : Tot (hash256) (decreases (length s))
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec update_multi_quads (s:seq quad32) (hash_orig:hash256) : Tot (hash256) (decreases (length s)) = if length s < 4 then hash_orig else let prefix, qs = split s (length s - 4) in let h_prefix = update_multi_quads prefix hash_orig in let hash = update_block h_prefix (quads_to_block_be qs) in hash
val update_multi_quads (s: seq quad32) (hash_orig: hash256) : Tot (hash256) (decreases (length s)) let rec update_multi_quads (s: seq quad32) (hash_orig: hash256) : Tot (hash256) (decreases (length s)) =
false
null
false
if length s < 4 then hash_orig else let prefix, qs = split s (length s - 4) in let h_prefix = update_multi_quads prefix hash_orig in let hash = update_block h_prefix (quads_to_block_be qs) in hash
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total", "" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.SHA.PPC64LE.SHA_helpers.hash256", "Prims.op_LessThan", "FStar.Seq.Base.length", "Prims.bool", "Vale.SHA.PPC64LE.SHA_helpers.update_block", "Vale.SHA.PPC64LE.SHA_helpers.quads_to_block_be", "Vale.SHA.PPC64LE.SHA_helpers.update_multi_quads", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.split", "Prims.op_Subtraction" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block)) val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) (ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig)) val sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_1_partial = opaque_make sigma_1_1_partial_def irreducible let sigma_1_1_partial_reveal = opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def val lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) (ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig)) val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a /\ hash.[1] == nat32_to_word b /\ hash.[2] == nat32_to_word c /\ hash.[3] == nat32_to_word d /\ hash.[4] == nat32_to_word e /\ hash.[5] == nat32_to_word f /\ hash.[6] == nat32_to_word g /\ hash.[7] == nat32_to_word h ) val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a.hi3 /\ hash.[1] == nat32_to_word b.hi3 /\ hash.[2] == nat32_to_word c.hi3 /\ hash.[3] == nat32_to_word d.hi3 /\ hash.[4] == nat32_to_word e.hi3 /\ hash.[5] == nat32_to_word f.hi3 /\ hash.[6] == nat32_to_word g.hi3 /\ hash.[7] == nat32_to_word h.hi3 ) val lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma (requires length hash == 8 /\ a.hi3 == word_to_nat32 hash.[0] /\ b.hi3 == word_to_nat32 hash.[1] /\ c.hi3 == word_to_nat32 hash.[2] /\ d.hi3 == word_to_nat32 hash.[3] /\ e.hi3 == word_to_nat32 hash.[4] /\ f.hi3 == word_to_nat32 hash.[5] /\ g.hi3 == word_to_nat32 hash.[6] /\ h.hi3 == word_to_nat32 hash.[7]) (ensures hash == make_seperated_hash_quad32 a b c d e f g h) val lemma_vsel32 (a b c:nat32) : Lemma (ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b))) val ch_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ (iand32 (inot32 x) z)) val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma (ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))) val maj_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))) val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block)) val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block)) val lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig)) val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig)) (* Abbreviations and lemmas for the code itself *) let k_reqs (k_seq:seq quad32) : prop0 = length k_seq == size_k_w_256 / 4 /\ (forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==> (k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\ (k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\ (k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\ (k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3])) let quads_to_block_be (qs:seq quad32) : block_w = let nat32_seq = Vale.Def.Words.Seq_s.seq_four_to_seq_BE qs in let f (n:nat{n < 16}) : word = nat32_to_word (if n < length nat32_seq then nat32_seq.[n] else 0) in init 16 f val lemma_quads_to_block_be (qs:seq quad32) : Lemma (requires length qs == 4) (ensures (let block = quads_to_block_be qs in forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==> (qs.[i]).hi3 == ws_opaque block (4 * i + 0) /\ (qs.[i]).hi2 == ws_opaque block (4 * i + 1) /\ (qs.[i]).lo1 == ws_opaque block (4 * i + 2) /\ (qs.[i]).lo0 == ws_opaque block (4 * i + 3))) let k_index (ks:seq quad32) (i:nat) : nat32 = if length ks = size_k_w_256 / 4 && i < size_k_w_256 then four_select ks.[(i/4)] (i % 4) else 0 val lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in let a0 = word_to_nat32 hash.[0] in let b0 = word_to_nat32 hash.[1] in let c0 = word_to_nat32 hash.[2] in let d0 = word_to_nat32 hash.[3] in let e0 = word_to_nat32 hash.[4] in let f0 = word_to_nat32 hash.[5] in let g0 = word_to_nat32 hash.[6] in let h0 = word_to_nat32 hash.[7] in let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in word_to_nat32 h.[0] == add_wrap t1 t2 /\ word_to_nat32 h.[1] == a0 /\ word_to_nat32 h.[2] == b0 /\ word_to_nat32 h.[3] == c0 /\ word_to_nat32 h.[4] == add_wrap d0 t1 /\ word_to_nat32 h.[5] == e0 /\ word_to_nat32 h.[6] == f0 /\ word_to_nat32 h.[7] == g0)) val lemma_ws_opaque (block:block_w) (t:counter) : Lemma (requires 16 <= t && t < size_k_w_256) (ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16)))) let repeat_range_vale_64 (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash val update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma (requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in make_seperated_hash_quad32 a b c d e f g h == repeat_range_vale_64 block hash_orig /\ a' == add_wrap_quad32 a a_old /\ b' == add_wrap_quad32 b b_old /\ c' == add_wrap_quad32 c c_old /\ d' == add_wrap_quad32 d d_old /\ e' == add_wrap_quad32 e e_old /\ f' == add_wrap_quad32 f f_old /\ g' == add_wrap_quad32 g g_old /\ h' == add_wrap_quad32 h h_old)) (ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block)) let rec update_multi_quads (s:seq quad32) (hash_orig:hash256) : Tot (hash256) (decreases (length s))
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_multi_quads (s: seq quad32) (hash_orig: hash256) : Tot (hash256) (decreases (length s))
[ "recursion" ]
Vale.SHA.PPC64LE.SHA_helpers.update_multi_quads
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> hash_orig: Vale.SHA.PPC64LE.SHA_helpers.hash256 -> Prims.Tot Vale.SHA.PPC64LE.SHA_helpers.hash256
{ "end_col": 8, "end_line": 267, "start_col": 2, "start_line": 261 }
Prims.Tot
val k_reqs (k_seq: seq quad32) : prop0
[ { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA2.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Sel", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.SHA.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let k_reqs (k_seq:seq quad32) : prop0 = length k_seq == size_k_w_256 / 4 /\ (forall i . {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256/4) ==> (k_seq.[i]).lo0 == word_to_nat32 (k.[4 * i]) /\ (k_seq.[i]).lo1 == word_to_nat32 (k.[4 * i + 1]) /\ (k_seq.[i]).hi2 == word_to_nat32 (k.[4 * i + 2]) /\ (k_seq.[i]).hi3 == word_to_nat32 (k.[4 * i + 3]))
val k_reqs (k_seq: seq quad32) : prop0 let k_reqs (k_seq: seq quad32) : prop0 =
false
null
false
length k_seq == size_k_w_256 / 4 /\ (forall i. {:pattern (index k_seq i)} 0 <= i /\ i < (size_k_w_256 / 4) ==> (k_seq.[ i ]).lo0 == word_to_nat32 (k.[ 4 * i ]) /\ (k_seq.[ i ]).lo1 == word_to_nat32 (k.[ 4 * i + 1 ]) /\ (k_seq.[ i ]).hi2 == word_to_nat32 (k.[ 4 * i + 2 ]) /\ (k_seq.[ i ]).hi3 == word_to_nat32 (k.[ 4 * i + 3 ]))
{ "checked_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti.checked", "dependencies": [ "Vale.SHA2.Wrapper.fsti.checked", "Vale.Lib.Seqs_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Sel.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Spec.Loops.fst.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.SHA.PPC64LE.SHA_helpers.fsti" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.l_and", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "Prims.op_Division", "Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256", "Prims.l_Forall", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.op_LessThanOrEqual", "Vale.Def.Words_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Types_s.nat32", "Vale.SHA.PPC64LE.SHA_helpers.op_String_Access", "Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32", "Vale.SHA.PPC64LE.SHA_helpers.word", "Vale.SHA.PPC64LE.SHA_helpers.k", "FStar.Mul.op_Star", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Prims.op_Addition", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "FStar.Seq.Base.index", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.SHA.PPC64LE.SHA_helpers open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Types_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open FStar.Seq open Vale.Arch.Types open Vale.Def.Sel open Vale.SHA2.Wrapper open Vale.Def.Words.Four_s unfold let (.[]) = FStar.Seq.index #reset-options "--max_fuel 0 --max_ifuel 0" // Specialize these definitions (from Spec.SHA2.fst) for SHA256 unfold let size_k_w_256 = 64 val word:Type0 (* Number of words for a block size *) let size_block_w_256 = 16 (* Define the size block in bytes *) let block_length = 4 (*word_length a*) * size_block_w_256 let block_w = m:seq word {length m = size_block_w_256} let counter = nat val k : (s:seq word {length s = size_k_w_256}) let hash256 = m:Seq.seq word {Seq.length m = 8} (* Input data. *) type byte = UInt8.t type bytes = Seq.seq byte (* Input data, multiple of a block length. *) let bytes_blocks = l:bytes { Seq.length l % block_length = 0 } // Hide various SHA2 definitions val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 // Hide some functions that operate on words & bytes val word_to_nat32 (x:word) : nat32 val nat32_to_word (x:nat32) : word //unfold let bytes_blocks256 = bytes_blocks SHA2_256 let repeat_range_vale (max:nat { max < size_k_w_256}) (block:block_w) (hash:hash256) = Spec.Loops.repeat_range 0 max (shuffle_core_opaque block) hash let update_multi_opaque_vale (hash:hash256) (blocks:bytes) : hash256 = if length blocks % size_k_w_256 = 0 then let b:bytes_blocks = blocks in update_multi_opaque hash b else hash val make_ordered_hash (abcd efgh:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word abcd.lo0 /\ hash.[1] == nat32_to_word abcd.lo1 /\ hash.[2] == nat32_to_word abcd.hi2 /\ hash.[3] == nat32_to_word abcd.hi3 /\ hash.[4] == nat32_to_word efgh.lo0 /\ hash.[5] == nat32_to_word efgh.lo1 /\ hash.[6] == nat32_to_word efgh.hi2 /\ hash.[7] == nat32_to_word efgh.hi3 ) val update_block (hash:hash256) (block:block_w): hash256 val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma (requires length blocks % 64 = 0) (ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) val sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_0_partial = opaque_make sigma_0_0_partial_def irreducible let sigma_0_0_partial_reveal = opaque_revealer (`%sigma_0_0_partial) sigma_0_0_partial sigma_0_0_partial_def val lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-15)) (ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block)) val sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 [@"opaque_to_smt"] let sigma_0_1_partial = opaque_make sigma_0_1_partial_def irreducible let sigma_0_1_partial_reveal = opaque_revealer (`%sigma_0_1_partial) sigma_0_1_partial sigma_0_1_partial_def val lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256 /\ src.hi3 == ws_opaque block (t-2)) (ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block)) val sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_0_partial = opaque_make sigma_1_0_partial_def irreducible let sigma_1_0_partial_reveal = opaque_revealer (`%sigma_1_0_partial) sigma_1_0_partial sigma_1_0_partial_def val lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) (ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig)) val sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 [@"opaque_to_smt"] let sigma_1_1_partial = opaque_make sigma_1_1_partial_def irreducible let sigma_1_1_partial_reveal = opaque_revealer (`%sigma_1_1_partial) sigma_1_1_partial sigma_1_1_partial_def val lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256 /\ src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) (ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig)) val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a /\ hash.[1] == nat32_to_word b /\ hash.[2] == nat32_to_word c /\ hash.[3] == nat32_to_word d /\ hash.[4] == nat32_to_word e /\ hash.[5] == nat32_to_word f /\ hash.[6] == nat32_to_word g /\ hash.[7] == nat32_to_word h ) val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256) (requires True) (ensures fun hash -> length hash == 8 /\ hash.[0] == nat32_to_word a.hi3 /\ hash.[1] == nat32_to_word b.hi3 /\ hash.[2] == nat32_to_word c.hi3 /\ hash.[3] == nat32_to_word d.hi3 /\ hash.[4] == nat32_to_word e.hi3 /\ hash.[5] == nat32_to_word f.hi3 /\ hash.[6] == nat32_to_word g.hi3 /\ hash.[7] == nat32_to_word h.hi3 ) val lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma (requires length hash == 8 /\ a.hi3 == word_to_nat32 hash.[0] /\ b.hi3 == word_to_nat32 hash.[1] /\ c.hi3 == word_to_nat32 hash.[2] /\ d.hi3 == word_to_nat32 hash.[3] /\ e.hi3 == word_to_nat32 hash.[4] /\ f.hi3 == word_to_nat32 hash.[5] /\ g.hi3 == word_to_nat32 hash.[6] /\ h.hi3 == word_to_nat32 hash.[7]) (ensures hash == make_seperated_hash_quad32 a b c d e f g h) val lemma_vsel32 (a b c:nat32) : Lemma (ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b))) val ch_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ (iand32 (inot32 x) z)) val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma (ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))) val maj_256 (x y z:nat32):Pure(nat32) (requires True) (ensures fun a -> a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))) val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block)) val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma (requires 16 <= t /\ t < size_k_w_256) (ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block)) val lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig)) val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma (requires t < size_k_w_256) (ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig)) (* Abbreviations and lemmas for the code itself *)
false
true
Vale.SHA.PPC64LE.SHA_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val k_reqs (k_seq: seq quad32) : prop0
[]
Vale.SHA.PPC64LE.SHA_helpers.k_reqs
{ "file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k_seq: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> Vale.Def.Prop_s.prop0
{ "end_col": 53, "end_line": 189, "start_col": 2, "start_line": 184 }
Prims.Tot
val return_stt_comp (u: universe) (a e p: term) (x: var) : term
[ { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Steel.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Steel.Wrapper", "short_module": null }, { "abbrev": 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 return_stt_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term = mk_stt_comp u a (pack_ln (Tv_App p (e, Q_Explicit))) (return_post_with_eq u a e p x)
val return_stt_comp (u: universe) (a e p: term) (x: var) : term let return_stt_comp (u: universe) (a e p: term) (x: var) : term =
false
null
false
mk_stt_comp u a (pack_ln (Tv_App p (e, Q_Explicit))) (return_post_with_eq u a e p x)
{ "checked_file": "Pulse.Steel.Wrapper.Typing.fsti.checked", "dependencies": [ "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Steel.Wrapper.Typing.fsti" }
[ "total" ]
[ "FStar.Reflection.Types.universe", "FStar.Reflection.Types.term", "FStar.Reflection.V2.Data.var", "Pulse.Reflection.Util.mk_stt_comp", "FStar.Reflection.V2.Builtins.pack_ln", "FStar.Reflection.V2.Data.Tv_App", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.Data.aqualv", "FStar.Reflection.V2.Data.Q_Explicit", "Pulse.Steel.Wrapper.Typing.return_post_with_eq" ]
[]
module Pulse.Steel.Wrapper.Typing open FStar.Reflection.V2 open Pulse.Reflection.Util module RT = FStar.Reflection.Typing let return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term = let x_tm = RT.var_as_term x in let eq2_tm = mk_eq2 u a x_tm e in let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in let star_tm = mk_star p_app_x (mk_pure eq2_tm) in mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ])
false
true
Pulse.Steel.Wrapper.Typing.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val return_stt_comp (u: universe) (a e p: term) (x: var) : term
[]
Pulse.Steel.Wrapper.Typing.return_stt_comp
{ "file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
u10: FStar.Reflection.Types.universe -> a: FStar.Reflection.Types.term -> e: FStar.Reflection.Types.term -> p: FStar.Reflection.Types.term -> x: FStar.Reflection.V2.Data.var -> FStar.Reflection.Types.term
{ "end_col": 35, "end_line": 18, "start_col": 2, "start_line": 16 }
Prims.Tot
val return_post_with_eq (u: universe) (a e p: term) (x: var) : term
[ { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Steel.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Steel.Wrapper", "short_module": null }, { "abbrev": 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 return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term = let x_tm = RT.var_as_term x in let eq2_tm = mk_eq2 u a x_tm e in let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in let star_tm = mk_star p_app_x (mk_pure eq2_tm) in mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ])
val return_post_with_eq (u: universe) (a e p: term) (x: var) : term let return_post_with_eq (u: universe) (a e p: term) (x: var) : term =
false
null
false
let x_tm = RT.var_as_term x in let eq2_tm = mk_eq2 u a x_tm e in let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in let star_tm = mk_star p_app_x (mk_pure eq2_tm) in mk_abs a Q_Explicit (RT.subst_term star_tm [RT.ND x 0])
{ "checked_file": "Pulse.Steel.Wrapper.Typing.fsti.checked", "dependencies": [ "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Steel.Wrapper.Typing.fsti" }
[ "total" ]
[ "FStar.Reflection.Types.universe", "FStar.Reflection.Types.term", "FStar.Reflection.V2.Data.var", "Pulse.Reflection.Util.mk_abs", "FStar.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.Typing.subst_term", "Prims.Cons", "FStar.Reflection.Typing.subst_elt", "FStar.Reflection.Typing.ND", "Prims.Nil", "Pulse.Reflection.Util.mk_star", "Pulse.Reflection.Util.mk_pure", "FStar.Reflection.V2.Builtins.pack_ln", "FStar.Reflection.V2.Data.Tv_App", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.Data.aqualv", "Pulse.Reflection.Util.mk_eq2", "FStar.Reflection.Typing.var_as_term" ]
[]
module Pulse.Steel.Wrapper.Typing open FStar.Reflection.V2 open Pulse.Reflection.Util module RT = FStar.Reflection.Typing
false
true
Pulse.Steel.Wrapper.Typing.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val return_post_with_eq (u: universe) (a e p: term) (x: var) : term
[]
Pulse.Steel.Wrapper.Typing.return_post_with_eq
{ "file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
u5: FStar.Reflection.Types.universe -> a: FStar.Reflection.Types.term -> e: FStar.Reflection.Types.term -> p: FStar.Reflection.Types.term -> x: FStar.Reflection.V2.Data.var -> FStar.Reflection.Types.term
{ "end_col": 59, "end_line": 13, "start_col": 80, "start_line": 8 }
Prims.Tot
val return_stt_atomic_comp (u: universe) (a e p: term) (x: var) : term
[ { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Steel.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Steel.Wrapper", "short_module": null }, { "abbrev": 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 return_stt_atomic_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term = mk_stt_atomic_comp u a emp_inames_tm (pack_ln (Tv_App p (e, Q_Explicit))) (return_post_with_eq u a e p x)
val return_stt_atomic_comp (u: universe) (a e p: term) (x: var) : term let return_stt_atomic_comp (u: universe) (a e p: term) (x: var) : term =
false
null
false
mk_stt_atomic_comp u a emp_inames_tm (pack_ln (Tv_App p (e, Q_Explicit))) (return_post_with_eq u a e p x)
{ "checked_file": "Pulse.Steel.Wrapper.Typing.fsti.checked", "dependencies": [ "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Steel.Wrapper.Typing.fsti" }
[ "total" ]
[ "FStar.Reflection.Types.universe", "FStar.Reflection.Types.term", "FStar.Reflection.V2.Data.var", "Pulse.Reflection.Util.mk_stt_atomic_comp", "Pulse.Reflection.Util.emp_inames_tm", "FStar.Reflection.V2.Builtins.pack_ln", "FStar.Reflection.V2.Data.Tv_App", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.Data.aqualv", "FStar.Reflection.V2.Data.Q_Explicit", "Pulse.Steel.Wrapper.Typing.return_post_with_eq" ]
[]
module Pulse.Steel.Wrapper.Typing open FStar.Reflection.V2 open Pulse.Reflection.Util module RT = FStar.Reflection.Typing let return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term = let x_tm = RT.var_as_term x in let eq2_tm = mk_eq2 u a x_tm e in let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in let star_tm = mk_star p_app_x (mk_pure eq2_tm) in mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ]) let return_stt_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term = mk_stt_comp u a (pack_ln (Tv_App p (e, Q_Explicit))) (return_post_with_eq u a e p x) val return_stt_typing (#g:env) (#u:universe) (#a:term) (#e:term) (#p:term) (x:var{None? (RT.lookup_bvar g x)}) (a_typing:RT.tot_typing g a (pack_ln (Tv_Type u))) (e_typing:RT.tot_typing g e a) (p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm)) : GTot (RT.tot_typing g (mk_stt_return u a e p) (return_stt_comp u a e p x)) let return_stt_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term = mk_stt_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p val return_stt_noeq_typing (#g:env) (#u:universe) (#a:term) (#x:term) (#p:term) (a_typing:RT.tot_typing g a (pack_ln (Tv_Type u))) (x_typing:RT.tot_typing g x a) (p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm)) : GTot (RT.tot_typing g (mk_stt_return_noeq u a x p) (return_stt_noeq_comp u a x p))
false
true
Pulse.Steel.Wrapper.Typing.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val return_stt_atomic_comp (u: universe) (a e p: term) (x: var) : term
[]
Pulse.Steel.Wrapper.Typing.return_stt_atomic_comp
{ "file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
u19: FStar.Reflection.Types.universe -> a: FStar.Reflection.Types.term -> e: FStar.Reflection.Types.term -> p: FStar.Reflection.Types.term -> x: FStar.Reflection.V2.Data.var -> FStar.Reflection.Types.term
{ "end_col": 35, "end_line": 55, "start_col": 2, "start_line": 53 }
Prims.Tot
val par_post (u: universe) (aL aR postL postR: term) (x: var) : term
[ { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Steel.Wrapper", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Steel.Wrapper", "short_module": null }, { "abbrev": 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 par_post (u:universe) (aL aR:term) (postL postR:term) (x:var) : term = let x_tm = RT.var_as_term x in let postL = pack_ln (Tv_App postL (mk_fst u u aL aR x_tm, Q_Explicit)) in let postR = pack_ln (Tv_App postR (mk_snd u u aL aR x_tm, Q_Explicit)) in let post = mk_star postL postR in RT.subst_term post [ RT.ND x 0 ]
val par_post (u: universe) (aL aR postL postR: term) (x: var) : term let par_post (u: universe) (aL aR postL postR: term) (x: var) : term =
false
null
false
let x_tm = RT.var_as_term x in let postL = pack_ln (Tv_App postL (mk_fst u u aL aR x_tm, Q_Explicit)) in let postR = pack_ln (Tv_App postR (mk_snd u u aL aR x_tm, Q_Explicit)) in let post = mk_star postL postR in RT.subst_term post [RT.ND x 0]
{ "checked_file": "Pulse.Steel.Wrapper.Typing.fsti.checked", "dependencies": [ "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Steel.Wrapper.Typing.fsti" }
[ "total" ]
[ "FStar.Reflection.Types.universe", "FStar.Reflection.Types.term", "FStar.Reflection.V2.Data.var", "FStar.Reflection.Typing.subst_term", "Prims.Cons", "FStar.Reflection.Typing.subst_elt", "FStar.Reflection.Typing.ND", "Prims.Nil", "Pulse.Reflection.Util.mk_star", "FStar.Reflection.V2.Builtins.pack_ln", "FStar.Reflection.V2.Data.Tv_App", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.Data.aqualv", "Pulse.Reflection.Util.mk_snd", "FStar.Reflection.V2.Data.Q_Explicit", "Pulse.Reflection.Util.mk_fst", "FStar.Reflection.Typing.var_as_term" ]
[]
module Pulse.Steel.Wrapper.Typing open FStar.Reflection.V2 open Pulse.Reflection.Util module RT = FStar.Reflection.Typing let return_post_with_eq (u:universe) (a:term) (e:term) (p:term) (x:var) : term = let x_tm = RT.var_as_term x in let eq2_tm = mk_eq2 u a x_tm e in let p_app_x = pack_ln (Tv_App p (x_tm, Q_Explicit)) in let star_tm = mk_star p_app_x (mk_pure eq2_tm) in mk_abs a Q_Explicit (RT.subst_term star_tm [ RT.ND x 0 ]) let return_stt_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term = mk_stt_comp u a (pack_ln (Tv_App p (e, Q_Explicit))) (return_post_with_eq u a e p x) val return_stt_typing (#g:env) (#u:universe) (#a:term) (#e:term) (#p:term) (x:var{None? (RT.lookup_bvar g x)}) (a_typing:RT.tot_typing g a (pack_ln (Tv_Type u))) (e_typing:RT.tot_typing g e a) (p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm)) : GTot (RT.tot_typing g (mk_stt_return u a e p) (return_stt_comp u a e p x)) let return_stt_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term = mk_stt_comp u a (pack_ln (Tv_App p (x, Q_Explicit))) p val return_stt_noeq_typing (#g:env) (#u:universe) (#a:term) (#x:term) (#p:term) (a_typing:RT.tot_typing g a (pack_ln (Tv_Type u))) (x_typing:RT.tot_typing g x a) (p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm)) : GTot (RT.tot_typing g (mk_stt_return_noeq u a x p) (return_stt_noeq_comp u a x p)) let return_stt_atomic_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term = mk_stt_atomic_comp u a emp_inames_tm (pack_ln (Tv_App p (e, Q_Explicit))) (return_post_with_eq u a e p x) val return_stt_atomic_typing (#g:env) (#u:universe) (#a:term) (#e:term) (#p:term) (x:var{None? (RT.lookup_bvar g x)}) (a_typing:RT.tot_typing g a (pack_ln (Tv_Type u))) (e_typing:RT.tot_typing g e a) (p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm)) : GTot (RT.tot_typing g (mk_stt_atomic_return u a e p) (return_stt_atomic_comp u a e p x)) let return_stt_atomic_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term = mk_stt_atomic_comp u a emp_inames_tm (pack_ln (Tv_App p (x, Q_Explicit))) p val return_stt_atomic_noeq_typing (#g:env) (#u:universe) (#a:term) (#x:term) (#p:term) (a_typing:RT.tot_typing g a (pack_ln (Tv_Type u))) (x_typing:RT.tot_typing g x a) (p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm)) : GTot (RT.tot_typing g (mk_stt_atomic_return_noeq u a x p) (return_stt_atomic_noeq_comp u a x p)) let return_stt_ghost_comp (u:universe) (a:term) (e:term) (p:term) (x:var) : term = mk_stt_ghost_comp u a emp_inames_tm (pack_ln (Tv_App p (e, Q_Explicit))) (return_post_with_eq u a e p x) val return_stt_ghost_typing (#g:env) (#u:universe) (#a:term) (#e:term) (#p:term) (x:var{None? (RT.lookup_bvar g x)}) (a_typing:RT.tot_typing g a (pack_ln (Tv_Type u))) (e_typing:RT.tot_typing g e a) (p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm)) : GTot (RT.tot_typing g (mk_stt_ghost_return u a e p) (return_stt_ghost_comp u a e p x)) let return_stt_ghost_noeq_comp (u:universe) (a:term) (x:term) (p:term) : term = mk_stt_ghost_comp u a emp_inames_tm (pack_ln (Tv_App p (x, Q_Explicit))) p val return_stt_ghost_noeq_typing (#g:env) (#u:universe) (#a:term) (#x:term) (#p:term) (a_typing:RT.tot_typing g a (pack_ln (Tv_Type u))) (x_typing:RT.tot_typing g x a) (p_typing:RT.tot_typing g p (mk_arrow (a, Q_Explicit) vprop_tm)) : GTot (RT.tot_typing g (mk_stt_ghost_return_noeq u a x p) (return_stt_ghost_noeq_comp u a x p)) (* g |- inv : bool -> vprop g |- cond : stt<0> bool (exists_ inv) inv g |- body : stt<0> unit (inv true) (fun _ -> exists_ inv) ------------------------------------------------------------------------- g |- while inv cond body : stt<0> unit (exists_ inv) (fun _ -> inv false) *) val while_typing (#g:env) (#inv:term) (#cond:term) (#body:term) (inv_typing:RT.tot_typing g inv (mk_arrow (bool_tm, Q_Explicit) vprop_tm)) (cond_typing:RT.tot_typing g cond (mk_stt_comp uzero bool_tm (mk_exists uzero bool_tm inv) inv)) (body_typing:RT.tot_typing g body (mk_stt_comp uzero unit_tm (pack_ln (Tv_App inv (true_tm, Q_Explicit))) (mk_abs unit_tm Q_Explicit (mk_exists uzero bool_tm inv)))) : RT.tot_typing g (mk_while inv cond body) (mk_stt_comp uzero unit_tm (mk_exists uzero bool_tm inv) (mk_abs unit_tm Q_Explicit (pack_ln (Tv_App inv (false_tm, Q_Explicit)))))
false
true
Pulse.Steel.Wrapper.Typing.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val par_post (u: universe) (aL aR postL postR: term) (x: var) : term
[]
Pulse.Steel.Wrapper.Typing.par_post
{ "file_name": "lib/steel/pulse/Pulse.Steel.Wrapper.Typing.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
u38: FStar.Reflection.Types.universe -> aL: FStar.Reflection.Types.term -> aR: FStar.Reflection.Types.term -> postL: FStar.Reflection.Types.term -> postR: FStar.Reflection.Types.term -> x: FStar.Reflection.V2.Data.var -> FStar.Reflection.Types.term
{ "end_col": 34, "end_line": 163, "start_col": 74, "start_line": 158 }