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
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a)
let block_t (a: sha2_alg) =
false
null
false
lbuffer uint8 (HD.block_len a)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Hash.Definitions.block_len" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold
false
true
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val block_t : a: Spec.Hash.Definitions.sha2_alg -> Type0
[]
Hacl.Impl.SHA2.Core.block_t
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.sha2_alg -> Type0
{ "end_col": 32, "end_line": 36, "start_col": 2, "start_line": 36 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul
let state_t (a: sha2_alg) (m: m_spec) =
false
null
false
lbuffer (element_t a m) 8ul
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Lib.Buffer.lbuffer", "Hacl.Spec.SHA2.Vec.element_t", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold
false
true
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val state_t : a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
[]
Hacl.Impl.SHA2.Core.state_t
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
{ "end_col": 29, "end_line": 32, "start_col": 2, "start_line": 32 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul
let ws_t (a: sha2_alg) (m: m_spec) =
false
null
false
lbuffer (element_t a m) 16ul
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Lib.Buffer.lbuffer", "Hacl.Spec.SHA2.Vec.element_t", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract
false
true
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ws_t : a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
[]
Hacl.Impl.SHA2.Core.ws_t
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
{ "end_col": 30, "end_line": 40, "start_col": 2, "start_line": 40 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x)
let preserves_sub_disjoint_multi #lanes #len #len' (b: lbuffer uint8 len) (r: multibuf lanes len') =
false
null
false
(forall a l (x: lbuffer a l). disjoint b x ==> disjoint_multi r x)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.MultiBuffer.multibuf", "Prims.l_Forall", "Prims.l_imp", "Lib.Buffer.disjoint", "Lib.Buffer.MUT", "Lib.MultiBuffer.disjoint_multi", "Prims.logical" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val preserves_sub_disjoint_multi : b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> r: Lib.MultiBuffer.multibuf lanes len' -> Prims.logical
[]
Hacl.Impl.SHA2.Core.preserves_sub_disjoint_multi
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> r: Lib.MultiBuffer.multibuf lanes len' -> Prims.logical
{ "end_col": 69, "end_line": 392, "start_col": 4, "start_line": 392 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 preserves_disjoint_multi #lanes #len #len' (b:multibuf lanes len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint_multi b x ==> disjoint_multi r x)
let preserves_disjoint_multi #lanes #len #len' (b: multibuf lanes len) (r: multibuf lanes len') =
false
null
false
(forall a l (x: lbuffer a l). disjoint_multi b x ==> disjoint_multi r x)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Lib.NTuple.flen", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "Prims.l_Forall", "Lib.Buffer.lbuffer", "Prims.l_imp", "Lib.MultiBuffer.disjoint_multi", "Prims.logical" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 200" let emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); () #pop-options noextract let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in hsub noextract let emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 700" let emit8 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 result in assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a)); copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a)); copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a)); copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a)); assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a)); assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a)); assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup8 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, (as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7)))))))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+| loc b7) h0 h1); assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf)); emit8_lemma #a #m (as_seq h0 hbuf); loc_multi8 result; assert (modifies_multi result h0 h1); () #pop-options inline_for_extraction noextract val emit: #a:sha2_alg -> #m:m_spec{is_supported a m} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit #a #m hbuf result = match lanes a m with | 1 -> emit1 #a #m hbuf result | 4 -> emit4 #a #m hbuf result | 8 -> emit8 #a #m hbuf result noextract
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val preserves_disjoint_multi : b: Lib.MultiBuffer.multibuf lanes len -> r: Lib.MultiBuffer.multibuf lanes len' -> Prims.logical
[]
Hacl.Impl.SHA2.Core.preserves_disjoint_multi
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.MultiBuffer.multibuf lanes len -> r: Lib.MultiBuffer.multibuf lanes len' -> Prims.logical
{ "end_col": 75, "end_line": 781, "start_col": 4, "start_line": 781 }
Prims.Tot
val padded_blocks (a: sha2_alg) (len: size_t{v len <= block_length a}) : n: size_t{v n == SpecVec.padded_blocks a (v len)}
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul
val padded_blocks (a: sha2_alg) (len: size_t{v len <= block_length a}) : n: size_t{v n == SpecVec.padded_blocks a (v len)} let padded_blocks (a: sha2_alg) (len: size_t{v len <= block_length a}) : n: size_t{v n == SpecVec.padded_blocks a (v len)} =
false
null
false
if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.block_length", "Lib.IntTypes.op_Less_Equals_Dot", "Lib.IntTypes.op_Plus_Bang", "Spec.Hash.Definitions.len_len", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.block_len", "Prims.bool", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Hacl.Spec.SHA2.Vec.padded_blocks" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)}
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val padded_blocks (a: sha2_alg) (len: size_t{v len <= block_length a}) : n: size_t{v n == SpecVec.padded_blocks a (v len)}
[]
Hacl.Impl.SHA2.Core.padded_blocks
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.sha2_alg -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len <= Spec.Hash.Definitions.block_length a} -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n == Hacl.Spec.SHA2.Vec.padded_blocks a (Lib.IntTypes.v len)}
{ "end_col": 67, "end_line": 357, "start_col": 2, "start_line": 357 }
FStar.Pervasives.Lemma
val load_blocks_spec1_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b)
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b)
val load_blocks_spec1_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) let load_blocks_spec1_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) =
false
null
true
LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "lemma" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.multiblock_spec", "Lib.Sequence.eq_intro", "Hacl.Spec.SHA2.Vec.element_t", "Hacl.Spec.SHA2.Vec.load_blocks", "Hacl.Impl.SHA2.Core.load_blocks_spec1", "Prims.unit", "Prims.l_True", "Prims.squash", "Hacl.Spec.SHA2.Vec.ws_spec", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b)
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_blocks_spec1_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b)
[]
Hacl.Impl.SHA2.Core.load_blocks_spec1_lemma
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.SHA2.Vec.multiblock_spec a m -> FStar.Pervasives.Lemma (ensures Hacl.Spec.SHA2.Vec.load_blocks b == Hacl.Impl.SHA2.Core.load_blocks_spec1 b)
{ "end_col": 61, "end_line": 86, "start_col": 2, "start_line": 86 }
Prims.Tot
val load_blocks_spec4 (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (b: multiblock_spec a m) : ws_spec a m
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
val load_blocks_spec4 (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (b: multiblock_spec a m) : ws_spec a m let load_blocks_spec4 (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (b: multiblock_spec a m) : ws_spec a m =
false
null
false
let b0 = b.(| 0 |) in let b1 = b.(| 1 |) in let b2 = b.(| 2 |) in let b3 = b.(| 3 |) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.multiblock_spec", "Lib.Sequence.create16", "Hacl.Spec.SHA2.Vec.element_t", "Hacl.Spec.SHA2.Vec.load_elementi", "FStar.Seq.Properties.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Hash.Definitions.block_length", "Lib.MultiBuffer.op_Lens_Access", "Lib.IntTypes.uint8", "Hacl.Spec.SHA2.Vec.ws_spec" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_blocks_spec4 (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (b: multiblock_spec a m) : ws_spec a m
[]
Hacl.Impl.SHA2.Core.load_blocks_spec4
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.SHA2.Vec.multiblock_spec a m -> Hacl.Spec.SHA2.Vec.ws_spec a m
{ "end_col": 48, "end_line": 152, "start_col": 103, "start_line": 130 }
FStar.Pervasives.Lemma
val lemma_len_lt_max_a_fits_size_t: a:sha2_alg -> len:size_t -> Lemma (v len `less_than_max_input_length` a)
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_len_lt_max_a_fits_size_t a len = match a with | SHA2_224 | SHA2_256 -> Math.Lemmas.pow2_lt_compat 61 32 | SHA2_384 | SHA2_512 -> Math.Lemmas.pow2_lt_compat 125 32
val lemma_len_lt_max_a_fits_size_t: a:sha2_alg -> len:size_t -> Lemma (v len `less_than_max_input_length` a) let lemma_len_lt_max_a_fits_size_t a len =
false
null
true
match a with | SHA2_224 | SHA2_256 -> Math.Lemmas.pow2_lt_compat 61 32 | SHA2_384 | SHA2_512 -> Math.Lemmas.pow2_lt_compat 125 32
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "lemma" ]
[ "Spec.Hash.Definitions.sha2_alg", "Lib.IntTypes.size_t", "FStar.Math.Lemmas.pow2_lt_compat", "Prims.unit" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 200" let emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); () #pop-options noextract let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in hsub noextract let emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 700" let emit8 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 result in assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a)); copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a)); copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a)); copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a)); assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a)); assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a)); assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup8 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, (as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7)))))))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+| loc b7) h0 h1); assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf)); emit8_lemma #a #m (as_seq h0 hbuf); loc_multi8 result; assert (modifies_multi result h0 h1); () #pop-options inline_for_extraction noextract val emit: #a:sha2_alg -> #m:m_spec{is_supported a m} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit #a #m hbuf result = match lanes a m with | 1 -> emit1 #a #m hbuf result | 4 -> emit4 #a #m hbuf result | 8 -> emit8 #a #m hbuf result noextract let preserves_disjoint_multi #lanes #len #len' (b:multibuf lanes len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint_multi b x ==> disjoint_multi r x) val lemma_len_lt_max_a_fits_size_t: a:sha2_alg -> len:size_t -> Lemma (v len `less_than_max_input_length` a)
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_len_lt_max_a_fits_size_t: a:sha2_alg -> len:size_t -> Lemma (v len `less_than_max_input_length` a)
[]
Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.sha2_alg -> len: Lib.IntTypes.size_t -> FStar.Pervasives.Lemma (ensures Spec.Hash.Definitions.less_than_max_input_length (Lib.IntTypes.v len) a)
{ "end_col": 60, "end_line": 789, "start_col": 2, "start_line": 787 }
Prims.Tot
val load_blocks_spec8 (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (b: multiblock_spec a m) : ws_spec a m
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
val load_blocks_spec8 (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (b: multiblock_spec a m) : ws_spec a m let load_blocks_spec8 (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (b: multiblock_spec a m) : ws_spec a m =
false
null
false
let b0 = b.(| 0 |) in let b1 = b.(| 1 |) in let b2 = b.(| 2 |) in let b3 = b.(| 3 |) in let b4 = b.(| 4 |) in let b5 = b.(| 5 |) in let b6 = b.(| 6 |) in let b7 = b.(| 7 |) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.multiblock_spec", "Lib.Sequence.create16", "Hacl.Spec.SHA2.Vec.element_t", "Hacl.Spec.SHA2.Vec.load_elementi", "FStar.Seq.Properties.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Hash.Definitions.block_length", "Lib.MultiBuffer.op_Lens_Access", "Lib.IntTypes.uint8", "Hacl.Spec.SHA2.Vec.ws_spec" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_blocks_spec8 (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (b: multiblock_spec a m) : ws_spec a m
[]
Hacl.Impl.SHA2.Core.load_blocks_spec8
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.SHA2.Vec.multiblock_spec a m -> Hacl.Spec.SHA2.Vec.ws_spec a m
{ "end_col": 48, "end_line": 230, "start_col": 103, "start_line": 204 }
FStar.HyperStack.ST.Stack
val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st
val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st =
true
null
false
match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Hacl.Impl.SHA2.Core.state_t", "Hacl.Spec.SHA2.Vec.lanes", "Prims.unit", "Hacl.Impl.SHA2.Core.transpose_state4", "Hacl.Impl.SHA2.Core.transpose_state8" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st))
[]
Hacl.Impl.SHA2.Core.transpose_state
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st: Hacl.Impl.SHA2.Core.state_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 28, "end_line": 582, "start_col": 2, "start_line": 579 }
FStar.HyperStack.ST.Stack
val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws
val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws =
true
null
false
match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Hacl.Impl.SHA2.Core.ws_t", "Hacl.Spec.SHA2.Vec.lanes", "Prims.unit", "Hacl.Impl.SHA2.Core.transpose_ws4", "Hacl.Impl.SHA2.Core.transpose_ws8" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
[]
Hacl.Impl.SHA2.Core.transpose_ws
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ws: Hacl.Impl.SHA2.Core.ws_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 25, "end_line": 336, "start_col": 2, "start_line": 333 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 get_multiblock_t (a:sha2_alg) (m:m_spec) = len:size_t -> b:multibuf (lanes a m) len -> i:size_t{v i < v len / block_length a} -> Stack (multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live_multi h b) (ensures fun h0 r h1 -> h0 == h1 /\ live_multi h1 r /\ preserves_disjoint_multi b r /\ (lemma_len_lt_max_a_fits_size_t a len; as_seq_multi h1 r == SpecVec.get_multiblock_spec (v len) (as_seq_multi h0 b) (v i)))
let get_multiblock_t (a: sha2_alg) (m: m_spec) =
false
null
false
len: size_t -> b: multibuf (lanes a m) len -> i: size_t{v i < v len / block_length a} -> Stack (multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live_multi h b) (ensures fun h0 r h1 -> h0 == h1 /\ live_multi h1 r /\ preserves_disjoint_multi b r /\ (lemma_len_lt_max_a_fits_size_t a len; as_seq_multi h1 r == SpecVec.get_multiblock_spec (v len) (as_seq_multi h0 b) (v i)))
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "Hacl.Spec.SHA2.Vec.lanes", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_Division", "Spec.Hash.Definitions.block_length", "Hacl.Hash.Definitions.block_len", "FStar.Monotonic.HyperStack.mem", "Lib.MultiBuffer.live_multi", "Prims.l_and", "Prims.eq2", "Hacl.Impl.SHA2.Core.preserves_disjoint_multi", "Lib.NTuple.ntuple", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8", "Lib.MultiBuffer.as_seq_multi", "Hacl.Spec.SHA2.Vec.get_multiblock_spec", "Prims.unit", "Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 200" let emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); () #pop-options noextract let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in hsub noextract let emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 700" let emit8 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 result in assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a)); copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a)); copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a)); copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a)); assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a)); assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a)); assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup8 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, (as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7)))))))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+| loc b7) h0 h1); assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf)); emit8_lemma #a #m (as_seq h0 hbuf); loc_multi8 result; assert (modifies_multi result h0 h1); () #pop-options inline_for_extraction noextract val emit: #a:sha2_alg -> #m:m_spec{is_supported a m} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit #a #m hbuf result = match lanes a m with | 1 -> emit1 #a #m hbuf result | 4 -> emit4 #a #m hbuf result | 8 -> emit8 #a #m hbuf result noextract let preserves_disjoint_multi #lanes #len #len' (b:multibuf lanes len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint_multi b x ==> disjoint_multi r x) val lemma_len_lt_max_a_fits_size_t: a:sha2_alg -> len:size_t -> Lemma (v len `less_than_max_input_length` a) let lemma_len_lt_max_a_fits_size_t a len = match a with | SHA2_224 | SHA2_256 -> Math.Lemmas.pow2_lt_compat 61 32 | SHA2_384 | SHA2_512 -> Math.Lemmas.pow2_lt_compat 125 32 inline_for_extraction noextract
false
true
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_multiblock_t : a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
[]
Hacl.Impl.SHA2.Core.get_multiblock_t
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
{ "end_col": 88, "end_line": 801, "start_col": 4, "start_line": 794 }
FStar.Pervasives.Lemma
val load_blocks_spec8_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b)
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b)
val load_blocks_spec8_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) let load_blocks_spec8_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) =
false
null
true
LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "lemma" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.multiblock_spec", "Lib.Sequence.eq_intro", "Hacl.Spec.SHA2.Vec.element_t", "Hacl.Spec.SHA2.Vec.load_blocks", "Hacl.Impl.SHA2.Core.load_blocks_spec8", "Prims.unit", "Prims.l_True", "Prims.squash", "Hacl.Spec.SHA2.Vec.ws_spec", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b)
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_blocks_spec8_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b)
[]
Hacl.Impl.SHA2.Core.load_blocks_spec8_lemma
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.SHA2.Vec.multiblock_spec a m -> FStar.Pervasives.Lemma (ensures Hacl.Spec.SHA2.Vec.load_blocks b == Hacl.Impl.SHA2.Core.load_blocks_spec8 b)
{ "end_col": 61, "end_line": 237, "start_col": 2, "start_line": 237 }
FStar.HyperStack.ST.Stack
val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws
val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws =
true
null
false
match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Lib.MultiBuffer.multibuf", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Hash.Definitions.block_len", "Hacl.Impl.SHA2.Core.ws_t", "Hacl.Impl.SHA2.Core.load_blocks1", "Prims.unit", "Hacl.Impl.SHA2.Core.load_blocks4", "Hacl.Impl.SHA2.Core.load_blocks8" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
[]
Hacl.Impl.SHA2.Core.load_blocks
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.MultiBuffer.multibuf (Hacl.Spec.SHA2.Vec.lanes a m) (Hacl.Hash.Definitions.block_len a) -> ws: Hacl.Impl.SHA2.Core.ws_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 26, "end_line": 294, "start_col": 2, "start_line": 291 }
FStar.HyperStack.ST.Stack
val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7'
val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st =
true
null
false
let st0', st1', st2', st3', st4', st5', st6', st7' = VecTranspose.transpose8x8 (st.(0ul), st.(1ul), st.(2ul), st.(3ul), st.(4ul), st.(5ul), st.(6ul), st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7'
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Impl.SHA2.Core.state_t", "Lib.IntVector.vec_t", "Spec.Hash.Definitions.word_t", "Lib.Buffer.create8", "Hacl.Spec.SHA2.Vec.element_t", "Prims.unit", "Lib.IntVector.Transpose.vec_t8", "Lib.IntVector.Transpose.transpose8x8", "FStar.Pervasives.Native.Mktuple8", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st))
[]
Hacl.Impl.SHA2.Core.transpose_state8
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st: Hacl.Impl.SHA2.Core.state_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 52, "end_line": 568, "start_col": 31, "start_line": 566 }
FStar.HyperStack.ST.Stack
val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7'
val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st =
true
null
false
let st0', st1', st2', st3' = VecTranspose.transpose4x4 (st.(0ul), st.(1ul), st.(2ul), st.(3ul)) in let st4', st5', st6', st7' = VecTranspose.transpose4x4 (st.(4ul), st.(5ul), st.(6ul), st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7'
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Impl.SHA2.Core.state_t", "Lib.IntVector.vec_t", "Spec.Hash.Definitions.word_t", "Lib.Buffer.create8", "Hacl.Spec.SHA2.Vec.element_t", "Prims.unit", "Lib.IntVector.Transpose.vec_t4", "Lib.IntVector.Transpose.transpose4x4", "FStar.Pervasives.Native.Mktuple4", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st))
[]
Hacl.Impl.SHA2.Core.transpose_state4
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st: Hacl.Impl.SHA2.Core.state_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 52, "end_line": 556, "start_col": 31, "start_line": 553 }
FStar.HyperStack.ST.Stack
val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws =
true
null
false
let ws0, ws1, ws2, ws3 = VecTranspose.transpose4x4 (ws.(0ul), ws.(1ul), ws.(2ul), ws.(3ul)) in let ws4, ws5, ws6, ws7 = VecTranspose.transpose4x4 (ws.(4ul), ws.(5ul), ws.(6ul), ws.(7ul)) in let ws8, ws9, ws10, ws11 = VecTranspose.transpose4x4 (ws.(8ul), ws.(9ul), ws.(10ul), ws.(11ul)) in let ws12, ws13, ws14, ws15 = VecTranspose.transpose4x4 (ws.(12ul), ws.(13ul), ws.(14ul), ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Impl.SHA2.Core.ws_t", "Lib.IntVector.vec_t", "Spec.Hash.Definitions.word_t", "Lib.Buffer.create16", "Hacl.Spec.SHA2.Vec.element_t", "Prims.unit", "Lib.IntVector.Transpose.vec_t4", "Lib.IntVector.Transpose.transpose4x4", "FStar.Pervasives.Native.Mktuple4", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
[]
Hacl.Impl.SHA2.Core.transpose_ws4
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ws: Hacl.Impl.SHA2.Core.ws_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 83, "end_line": 309, "start_col": 28, "start_line": 304 }
FStar.Pervasives.Lemma
val load_blocks_spec4_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b)
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b)
val load_blocks_spec4_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) let load_blocks_spec4_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) =
false
null
true
LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "lemma" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.multiblock_spec", "Lib.Sequence.eq_intro", "Hacl.Spec.SHA2.Vec.element_t", "Hacl.Spec.SHA2.Vec.load_blocks", "Hacl.Impl.SHA2.Core.load_blocks_spec4", "Prims.unit", "Prims.l_True", "Prims.squash", "Hacl.Spec.SHA2.Vec.ws_spec", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b)
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_blocks_spec4_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (b: multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b)
[]
Hacl.Impl.SHA2.Core.load_blocks_spec4_lemma
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.SHA2.Vec.multiblock_spec a m -> FStar.Pervasives.Lemma (ensures Hacl.Spec.SHA2.Vec.load_blocks b == Hacl.Impl.SHA2.Core.load_blocks_spec4 b)
{ "end_col": 61, "end_line": 159, "start_col": 2, "start_line": 159 }
FStar.HyperStack.ST.Stack
val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws =
true
null
false
let ws0, ws1, ws2, ws3, ws4, ws5, ws6, ws7 = VecTranspose.transpose8x8 (ws.(0ul), ws.(1ul), ws.(2ul), ws.(3ul), ws.(4ul), ws.(5ul), ws.(6ul), ws.(7ul)) in let ws8, ws9, ws10, ws11, ws12, ws13, ws14, ws15 = VecTranspose.transpose8x8 (ws.(8ul), ws.(9ul), ws.(10ul), ws.(11ul), ws.(12ul), ws.(13ul), ws.(14ul), ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Impl.SHA2.Core.ws_t", "Lib.IntVector.vec_t", "Spec.Hash.Definitions.word_t", "Lib.Buffer.create16", "Hacl.Spec.SHA2.Vec.element_t", "Prims.unit", "Lib.IntVector.Transpose.vec_t8", "Lib.IntVector.Transpose.transpose8x8", "FStar.Pervasives.Native.Mktuple8", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws))
[]
Hacl.Impl.SHA2.Core.transpose_ws8
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ws: Hacl.Impl.SHA2.Core.ws_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 83, "end_line": 322, "start_col": 28, "start_line": 319 }
FStar.Pervasives.Lemma
val emit1_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq)
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq)
val emit1_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) let emit1_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) =
false
null
true
Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "lemma" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "FStar.Mul.op_Star", "Spec.Hash.Definitions.word_length", "Lib.NTuple.eq_intro", "FStar.Seq.Properties.lseq", "Spec.Hash.Definitions.hash_length", "Hacl.Impl.SHA2.Core.emit1_spec", "Hacl.Spec.SHA2.Vec.emit", "Prims.unit", "Prims.l_True", "Prims.squash", "Hacl.Spec.SHA2.Vec.multiseq", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq)
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emit1_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq)
[]
Hacl.Impl.SHA2.Core.emit1_lemma
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hseq: Lib.Sequence.lseq Lib.IntTypes.uint8 ((Hacl.Spec.SHA2.Vec.lanes a m * 8) * Spec.Hash.Definitions.word_length a) -> FStar.Pervasives.Lemma (ensures Hacl.Impl.SHA2.Core.emit1_spec hseq == Hacl.Spec.SHA2.Vec.emit hseq)
{ "end_col": 71, "end_line": 612, "start_col": 2, "start_line": 612 }
Prims.Tot
val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last
val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last =
false
null
false
match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Spec.Hash.Definitions.len_len", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.block_length", "Lib.MultiBuffer.multibuf", "Hacl.Spec.SHA2.Vec.lanes", "Prims.l_or", "Prims.eq2", "Prims.int", "Lib.IntTypes.range", "Prims.op_disEquality", "FStar.Mul.op_Star", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.block_len", "Hacl.Impl.SHA2.Core.load_last1", "FStar.Pervasives.Native.tuple2", "Hacl.Impl.SHA2.Core.load_last4", "Hacl.Impl.SHA2.Core.load_last8" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m
[]
Hacl.Impl.SHA2.Core.load_last
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.SHA2.Core.load_last_t a m
{ "end_col": 51, "end_line": 543, "start_col": 2, "start_line": 540 }
FStar.HyperStack.ST.Stack
val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_ws #a #m b ws = load_blocks b ws; transpose_ws ws
val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws =
true
null
false
load_blocks b ws; transpose_ws ws
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Lib.MultiBuffer.multibuf", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Hash.Definitions.block_len", "Hacl.Impl.SHA2.Core.ws_t", "Hacl.Impl.SHA2.Core.transpose_ws", "Prims.unit", "Hacl.Impl.SHA2.Core.load_blocks" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b))
[]
Hacl.Impl.SHA2.Core.load_ws
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.MultiBuffer.multibuf (Hacl.Spec.SHA2.Vec.lanes a m) (Hacl.Hash.Definitions.block_len a) -> ws: Hacl.Impl.SHA2.Core.ws_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 17, "end_line": 350, "start_col": 2, "start_line": 349 }
Prims.Tot
val emit1_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a)
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub
val emit1_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) let emit1_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) =
false
null
false
let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "FStar.Mul.op_Star", "Spec.Hash.Definitions.word_length", "Lib.NTuple.ntup1", "FStar.Seq.Properties.lseq", "Spec.Hash.Definitions.hash_length", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.l_and", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.op_Multiply", "Prims.op_Addition", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.sub", "Hacl.Spec.SHA2.Vec.multiseq" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) :
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emit1_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 1}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a)
[]
Hacl.Impl.SHA2.Core.emit1_spec
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hseq: Lib.Sequence.lseq Lib.IntTypes.uint8 ((Hacl.Spec.SHA2.Vec.lanes a m * 8) * Spec.Hash.Definitions.word_length a) -> Hacl.Spec.SHA2.Vec.multiseq (Hacl.Spec.SHA2.Vec.lanes a m) (Spec.Hash.Definitions.hash_length a)
{ "end_col": 12, "end_line": 605, "start_col": 2, "start_line": 603 }
FStar.Pervasives.Lemma
val emit4_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq)
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq)
val emit4_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) let emit4_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) =
false
null
true
Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "lemma" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "FStar.Mul.op_Star", "Spec.Hash.Definitions.word_length", "Lib.NTuple.eq_intro", "FStar.Seq.Properties.lseq", "Spec.Hash.Definitions.hash_length", "Hacl.Impl.SHA2.Core.emit4_spec", "Hacl.Spec.SHA2.Vec.emit", "Prims.unit", "Prims.l_True", "Prims.squash", "Hacl.Spec.SHA2.Vec.multiseq", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq)
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emit4_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq)
[]
Hacl.Impl.SHA2.Core.emit4_lemma
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hseq: Lib.Sequence.lseq Lib.IntTypes.uint8 ((Hacl.Spec.SHA2.Vec.lanes a m * 8) * Spec.Hash.Definitions.word_length a) -> FStar.Pervasives.Lemma (ensures Hacl.Impl.SHA2.Core.emit4_spec hseq == Hacl.Spec.SHA2.Vec.emit hseq)
{ "end_col": 71, "end_line": 651, "start_col": 2, "start_line": 651 }
FStar.Pervasives.Lemma
val emit8_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq)
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq)
val emit8_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) let emit8_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) =
false
null
true
Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "lemma" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "FStar.Mul.op_Star", "Spec.Hash.Definitions.word_length", "Lib.NTuple.eq_intro", "FStar.Seq.Properties.lseq", "Spec.Hash.Definitions.hash_length", "Hacl.Impl.SHA2.Core.emit8_spec", "Hacl.Spec.SHA2.Vec.emit", "Prims.unit", "Prims.l_True", "Prims.squash", "Hacl.Spec.SHA2.Vec.multiseq", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 200" let emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); () #pop-options noextract let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in hsub noextract let emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq)
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emit8_lemma (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq)
[]
Hacl.Impl.SHA2.Core.emit8_lemma
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hseq: Lib.Sequence.lseq Lib.IntTypes.uint8 ((Hacl.Spec.SHA2.Vec.lanes a m * 8) * Spec.Hash.Definitions.word_length a) -> FStar.Pervasives.Lemma (ensures Hacl.Impl.SHA2.Core.emit8_spec hseq == Hacl.Spec.SHA2.Vec.emit hseq)
{ "end_col": 71, "end_line": 714, "start_col": 2, "start_line": 714 }
FStar.HyperStack.ST.Stack
val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi)))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a))
val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi =
true
null
false
[@@ inline_let ]let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a))
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Impl.SHA2.Core.ws_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Hash.Definitions.block_len", "Prims.op_Division", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Buffer.op_Array_Assignment", "Hacl.Spec.SHA2.Vec.element_t", "FStar.UInt32.__uint_to_t", "Prims.unit", "Lib.IntVector.vec_load_be", "Spec.Hash.Definitions.word_t", "Lib.IntVector.vec_t", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.mul", "Lib.IntTypes.mk_int", "Lib.IntTypes.numbytes", "Lib.Buffer.sub", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "Hacl.Hash.Definitions.word_len", "Hacl.Spec.SHA2.Vec.lanes_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi)))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi)))
[]
Hacl.Impl.SHA2.Core.set_wsi
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ws: Hacl.Impl.SHA2.Core.ws_t a m -> i: Lib.IntTypes.size_t{Lib.IntTypes.v i < 16} -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Hash.Definitions.block_len a) -> bi: Lib.IntTypes.size_t{Lib.IntTypes.v bi < 16 / Hacl.Spec.SHA2.Vec.lanes a m} -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 102, "end_line": 57, "start_col": 2, "start_line": 55 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b))
let load_last_t (a: sha2_alg) (m: m_spec{is_supported a m}) =
false
null
false
totlen_buf: lbuffer uint8 (len_len a) -> len: size_t{v len <= block_length a} -> b: multibuf (lanes a m) len -> fin: size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last: lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create ((lanes a m * 2) * block_length a) (u8 0)) (ensures fun h0 (l0, l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b))
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Spec.Hash.Definitions.len_len", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.block_length", "Lib.MultiBuffer.multibuf", "Hacl.Spec.SHA2.Vec.lanes", "Prims.l_or", "Prims.eq2", "Prims.int", "Lib.IntTypes.range", "Prims.op_disEquality", "FStar.Mul.op_Star", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.block_len", "FStar.Pervasives.Native.tuple2", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.MultiBuffer.live_multi", "Lib.MultiBuffer.disjoint_multi", "Lib.Buffer.disjoint", "Lib.Sequence.seq", "Prims.nat", "FStar.Seq.Base.length", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.create", "Lib.IntTypes.u8", "Prims.l_Forall", "Prims.l_imp", "Prims.op_LessThan", "Lib.Sequence.index", "Lib.Buffer.as_seq", "Lib.Sequence.create", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Hacl.Impl.SHA2.Core.preserves_sub_disjoint_multi", "Hacl.Spec.SHA2.Vec.multiseq", "FStar.Pervasives.Native.Mktuple2", "Lib.MultiBuffer.multiseq", "Lib.MultiBuffer.as_seq_multi", "Hacl.Spec.SHA2.Vec.load_last" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_last_t : a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec{Hacl.Spec.SHA2.Vec.is_supported a m} -> Type0
[]
Hacl.Impl.SHA2.Core.load_last_t
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec{Hacl.Spec.SHA2.Vec.is_supported a m} -> Type0
{ "end_col": 87, "end_line": 411, "start_col": 4, "start_line": 397 }
Prims.Tot
val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1)
val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m let load_last1 #a #m totlen_buf len b fin last =
false
null
false
let h0 = ST.get () in let b0 = b.(| 0 |) in let l0, l1 = load_last_blocks #a totlen_buf len b0 fin last in let lb0:multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1:multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get () in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0, lb1)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Spec.Hash.Definitions.len_len", "Lib.IntTypes.size_t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.block_length", "Lib.MultiBuffer.multibuf", "Prims.l_or", "Prims.eq2", "Lib.IntTypes.range", "Prims.op_disEquality", "FStar.Mul.op_Star", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.block_len", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "FStar.Pervasives.reveal_opaque", "Lib.Sequence.lseq", "Spec.Hash.Definitions.len_length", "Prims.nat", "Prims.op_GreaterThanOrEqual", "Hacl.Spec.SHA2.Vec.multiseq", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.SHA2.Vec.load_last", "Prims._assert", "Lib.MultiBuffer.multiseq", "Lib.MultiBuffer.as_seq_multi", "Hacl.Spec.SHA2.Vec.load_last1", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.NTuple.eq_intro", "FStar.Seq.Properties.lseq", "Lib.NTuple.ntup1", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Hacl.Impl.SHA2.Core.load_last_blocks", "Lib.MultiBuffer.op_Lens_Access" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 250, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m
[]
Hacl.Impl.SHA2.Core.load_last1
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.SHA2.Core.load_last_t a m
{ "end_col": 11, "end_line": 432, "start_col": 48, "start_line": 418 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 get_multilast_t (a:sha2_alg) (m:m_spec) = len:size_t -> b:multibuf (lanes a m) len -> Stack (multibuf (lanes a m) (len %. HD.block_len a)) (requires fun h -> live_multi h b) (ensures fun h0 r h1 -> h0 == h1 /\ live_multi h1 r /\ preserves_disjoint_multi b r /\ (lemma_len_lt_max_a_fits_size_t a len; as_seq_multi h1 r == SpecVec.get_multilast_spec #a #m (v len) (as_seq_multi h0 b)))
let get_multilast_t (a: sha2_alg) (m: m_spec) =
false
null
false
len: size_t -> b: multibuf (lanes a m) len -> Stack (multibuf (lanes a m) (len %. HD.block_len a)) (requires fun h -> live_multi h b) (ensures fun h0 r h1 -> h0 == h1 /\ live_multi h1 r /\ preserves_disjoint_multi b r /\ (lemma_len_lt_max_a_fits_size_t a len; as_seq_multi h1 r == SpecVec.get_multilast_spec #a #m (v len) (as_seq_multi h0 b)))
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "Hacl.Spec.SHA2.Vec.lanes", "Lib.IntTypes.op_Percent_Dot", "Lib.IntTypes.U32", "Hacl.Hash.Definitions.block_len", "FStar.Monotonic.HyperStack.mem", "Lib.MultiBuffer.live_multi", "Prims.l_and", "Prims.eq2", "Hacl.Impl.SHA2.Core.preserves_disjoint_multi", "Lib.NTuple.ntuple", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8", "Prims.op_Modulus", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.block_length", "Lib.MultiBuffer.as_seq_multi", "Hacl.Spec.SHA2.Vec.get_multilast_spec", "Prims.unit", "Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 200" let emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); () #pop-options noextract let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in hsub noextract let emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 700" let emit8 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 result in assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a)); copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a)); copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a)); copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a)); assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a)); assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a)); assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup8 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, (as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7)))))))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+| loc b7) h0 h1); assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf)); emit8_lemma #a #m (as_seq h0 hbuf); loc_multi8 result; assert (modifies_multi result h0 h1); () #pop-options inline_for_extraction noextract val emit: #a:sha2_alg -> #m:m_spec{is_supported a m} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit #a #m hbuf result = match lanes a m with | 1 -> emit1 #a #m hbuf result | 4 -> emit4 #a #m hbuf result | 8 -> emit8 #a #m hbuf result noextract let preserves_disjoint_multi #lanes #len #len' (b:multibuf lanes len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint_multi b x ==> disjoint_multi r x) val lemma_len_lt_max_a_fits_size_t: a:sha2_alg -> len:size_t -> Lemma (v len `less_than_max_input_length` a) let lemma_len_lt_max_a_fits_size_t a len = match a with | SHA2_224 | SHA2_256 -> Math.Lemmas.pow2_lt_compat 61 32 | SHA2_384 | SHA2_512 -> Math.Lemmas.pow2_lt_compat 125 32 inline_for_extraction noextract let get_multiblock_t (a:sha2_alg) (m:m_spec) = len:size_t -> b:multibuf (lanes a m) len -> i:size_t{v i < v len / block_length a} -> Stack (multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live_multi h b) (ensures fun h0 r h1 -> h0 == h1 /\ live_multi h1 r /\ preserves_disjoint_multi b r /\ (lemma_len_lt_max_a_fits_size_t a len; as_seq_multi h1 r == SpecVec.get_multiblock_spec (v len) (as_seq_multi h0 b) (v i))) inline_for_extraction noextract val get_multiblock: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multiblock_t a m let get_multiblock #a #m len b i = lemma_len_lt_max_a_fits_size_t a len; let h0 = ST.get() in match lanes a m with | 1 -> let b0 = NTup.tup1 b in let b' = sub b0 (i *! HD.block_len a) (HD.block_len a) in let mb' = NTup.ntup1 b' in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb') (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb' | 4 -> let (b0,(b1,(b2,b3))) = NTup.tup4 b in let bl0 = sub b0 (i *! HD.block_len a) (HD.block_len a) in let bl1 = sub b1 (i *! HD.block_len a) (HD.block_len a) in let bl2 = sub b2 (i *! HD.block_len a) (HD.block_len a) in let bl3 = sub b3 (i *! HD.block_len a) (HD.block_len a) in let mb = NTup.ntup4 (bl0, (bl1, (bl2, bl3))) in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb | 8 -> let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let bl0 = sub b0 (i *! HD.block_len a) (HD.block_len a) in let bl1 = sub b1 (i *! HD.block_len a) (HD.block_len a) in let bl2 = sub b2 (i *! HD.block_len a) (HD.block_len a) in let bl3 = sub b3 (i *! HD.block_len a) (HD.block_len a) in let bl4 = sub b4 (i *! HD.block_len a) (HD.block_len a) in let bl5 = sub b5 (i *! HD.block_len a) (HD.block_len a) in let bl6 = sub b6 (i *! HD.block_len a) (HD.block_len a) in let bl7 = sub b7 (i *! HD.block_len a) (HD.block_len a) in let mb = NTup.ntup8 (bl0, (bl1, (bl2, (bl3, (bl4, (bl5, (bl6, bl7))))))) in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb inline_for_extraction noextract
false
true
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_multilast_t : a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
[]
Hacl.Impl.SHA2.Core.get_multilast_t
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
{ "end_col": 87, "end_line": 851, "start_col": 4, "start_line": 845 }
Prims.Tot
val emit4_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a)
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub
val emit4_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) let emit4_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) =
false
null
false
let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub:multiseq 4 (hash_length a) = ntup4 (h0, (h1, (h2, h3))) in hsub
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "FStar.Mul.op_Star", "Spec.Hash.Definitions.word_length", "Hacl.Spec.SHA2.Vec.multiseq", "Spec.Hash.Definitions.hash_length", "Lib.NTuple.ntup4", "FStar.Seq.Properties.lseq", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.l_and", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.op_Multiply", "Prims.op_Addition", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.sub" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a)
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emit4_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 4}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a)
[]
Hacl.Impl.SHA2.Core.emit4_spec
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hseq: Lib.Sequence.lseq Lib.IntTypes.uint8 ((Hacl.Spec.SHA2.Vec.lanes a m * 8) * Spec.Hash.Definitions.word_length a) -> Hacl.Spec.SHA2.Vec.multiseq (Hacl.Spec.SHA2.Vec.lanes a m) (Spec.Hash.Definitions.hash_length a)
{ "end_col": 6, "end_line": 644, "start_col": 2, "start_line": 638 }
FStar.HyperStack.ST.Stack
val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st
val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf =
true
null
false
transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Hacl.Impl.SHA2.Core.state_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.size", "Hacl.Spec.SHA2.Vec.lanes", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.word_len", "Lib.IntVector.Serialize.vecs_store_be", "Spec.Hash.Definitions.word_t", "Prims.unit", "Hacl.Impl.SHA2.Core.transpose_state" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st))
[]
Hacl.Impl.SHA2.Core.store_state
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st: Hacl.Impl.SHA2.Core.state_t a m -> hbuf: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Lib.IntTypes.size (Hacl.Spec.SHA2.Vec.lanes a m) *! 8ul *! Hacl.Hash.Definitions.word_len a ) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 47, "end_line": 597, "start_col": 2, "start_line": 596 }
FStar.HyperStack.ST.Stack
val emit: #a:sha2_alg -> #m:m_spec{is_supported a m} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 emit #a #m hbuf result = match lanes a m with | 1 -> emit1 #a #m hbuf result | 4 -> emit4 #a #m hbuf result | 8 -> emit8 #a #m hbuf result
val emit: #a:sha2_alg -> #m:m_spec{is_supported a m} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit #a #m hbuf result =
true
null
false
match lanes a m with | 1 -> emit1 #a #m hbuf result | 4 -> emit4 #a #m hbuf result | 8 -> emit8 #a #m hbuf result
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.size", "Hacl.Spec.SHA2.Vec.lanes", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.word_len", "Lib.MultiBuffer.multibuf", "Hacl.Hash.Definitions.hash_len", "Hacl.Impl.SHA2.Core.emit1", "Prims.unit", "Hacl.Impl.SHA2.Core.emit4", "Hacl.Impl.SHA2.Core.emit8" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 200" let emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); () #pop-options noextract let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in hsub noextract let emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 700" let emit8 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 result in assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a)); copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a)); copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a)); copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a)); assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a)); assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a)); assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup8 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, (as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7)))))))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+| loc b7) h0 h1); assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf)); emit8_lemma #a #m (as_seq h0 hbuf); loc_multi8 result; assert (modifies_multi result h0 h1); () #pop-options inline_for_extraction noextract val emit: #a:sha2_alg -> #m:m_spec{is_supported a m} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emit: #a:sha2_alg -> #m:m_spec{is_supported a m} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
[]
Hacl.Impl.SHA2.Core.emit
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hbuf: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Lib.IntTypes.size (Hacl.Spec.SHA2.Vec.lanes a m) *! 8ul *! Hacl.Hash.Definitions.word_len a ) -> result: Lib.MultiBuffer.multibuf (Hacl.Spec.SHA2.Vec.lanes a m) (Hacl.Hash.Definitions.hash_len a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 32, "end_line": 776, "start_col": 2, "start_line": 773 }
FStar.HyperStack.ST.Stack
val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1)
val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result =
true
null
false
let h0 = ST.get () in copy result.(| 0 |) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get () in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.word_len", "Lib.MultiBuffer.multibuf", "Hacl.Hash.Definitions.hash_len", "Prims._assert", "Lib.MultiBuffer.modifies_multi", "Prims.unit", "Hacl.Impl.SHA2.Core.emit1_lemma", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.NTuple.eq_intro", "FStar.Seq.Properties.lseq", "Lib.IntTypes.v", "Lib.MultiBuffer.as_seq_multi", "Hacl.Impl.SHA2.Core.emit1_spec", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.copy", "Lib.MultiBuffer.op_Lens_Access", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.sub" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
[]
Hacl.Impl.SHA2.Core.emit1
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hbuf: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (8ul *! Hacl.Hash.Definitions.word_len a) -> result: Lib.MultiBuffer.multibuf (Hacl.Spec.SHA2.Vec.lanes a m) (Hacl.Hash.Definitions.hash_len a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 38, "end_line": 631, "start_col": 29, "start_line": 625 }
FStar.HyperStack.ST.Stack
val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b)))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1)
val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) let load_last_blocks #a totlen_buf len b fin last =
true
null
false
let h0 = ST.get () in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0:lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1:lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get () in assert (modifies (loc last) h0 h1); (last0, last1)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Spec.Hash.Definitions.len_len", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.block_length", "Prims.l_or", "Prims.eq2", "Prims.int", "Lib.IntTypes.range", "Prims.op_disEquality", "FStar.Mul.op_Star", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.block_len", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Prims._assert", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Buffer.MUT", "FStar.Pervasives.Native.tuple2", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.sub", "Lib.Buffer.update_sub", "Lib.IntTypes.op_Subtraction_Dot", "Lib.Buffer.op_Array_Assignment", "Lib.IntTypes.u8" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b)))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b)))
[]
Hacl.Impl.SHA2.Core.load_last_blocks
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
totlen_buf: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Spec.Hash.Definitions.len_len a) -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len <= Spec.Hash.Definitions.block_length a} -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> fin: Lib.IntTypes.size_t { Lib.IntTypes.v fin == Spec.Hash.Definitions.block_length a \/ Lib.IntTypes.v fin == 2 * Spec.Hash.Definitions.block_length a } -> last: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (2ul *! Hacl.Hash.Definitions.block_len a) -> FStar.HyperStack.ST.Stack (Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Hash.Definitions.block_len a) * Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Hash.Definitions.block_len a))
{ "end_col": 15, "end_line": 386, "start_col": 51, "start_line": 377 }
Prims.Tot
val get_multiblock: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multiblock_t a m
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 get_multiblock #a #m len b i = lemma_len_lt_max_a_fits_size_t a len; let h0 = ST.get() in match lanes a m with | 1 -> let b0 = NTup.tup1 b in let b' = sub b0 (i *! HD.block_len a) (HD.block_len a) in let mb' = NTup.ntup1 b' in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb') (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb' | 4 -> let (b0,(b1,(b2,b3))) = NTup.tup4 b in let bl0 = sub b0 (i *! HD.block_len a) (HD.block_len a) in let bl1 = sub b1 (i *! HD.block_len a) (HD.block_len a) in let bl2 = sub b2 (i *! HD.block_len a) (HD.block_len a) in let bl3 = sub b3 (i *! HD.block_len a) (HD.block_len a) in let mb = NTup.ntup4 (bl0, (bl1, (bl2, bl3))) in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb | 8 -> let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let bl0 = sub b0 (i *! HD.block_len a) (HD.block_len a) in let bl1 = sub b1 (i *! HD.block_len a) (HD.block_len a) in let bl2 = sub b2 (i *! HD.block_len a) (HD.block_len a) in let bl3 = sub b3 (i *! HD.block_len a) (HD.block_len a) in let bl4 = sub b4 (i *! HD.block_len a) (HD.block_len a) in let bl5 = sub b5 (i *! HD.block_len a) (HD.block_len a) in let bl6 = sub b6 (i *! HD.block_len a) (HD.block_len a) in let bl7 = sub b7 (i *! HD.block_len a) (HD.block_len a) in let mb = NTup.ntup8 (bl0, (bl1, (bl2, (bl3, (bl4, (bl5, (bl6, bl7))))))) in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb
val get_multiblock: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multiblock_t a m let get_multiblock #a #m len b i =
false
null
false
lemma_len_lt_max_a_fits_size_t a len; let h0 = ST.get () in match lanes a m with | 1 -> let b0 = NTup.tup1 b in let b' = sub b0 (i *! HD.block_len a) (HD.block_len a) in let mb' = NTup.ntup1 b' in let h1 = ST.get () in NTup.eq_intro (as_seq_multi h1 mb') (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb' | 4 -> let b0, (b1, (b2, b3)) = NTup.tup4 b in let bl0 = sub b0 (i *! HD.block_len a) (HD.block_len a) in let bl1 = sub b1 (i *! HD.block_len a) (HD.block_len a) in let bl2 = sub b2 (i *! HD.block_len a) (HD.block_len a) in let bl3 = sub b3 (i *! HD.block_len a) (HD.block_len a) in let mb = NTup.ntup4 (bl0, (bl1, (bl2, bl3))) in let h1 = ST.get () in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb | 8 -> let b0, (b1, (b2, (b3, (b4, (b5, (b6, b7)))))) = NTup.tup8 b in let bl0 = sub b0 (i *! HD.block_len a) (HD.block_len a) in let bl1 = sub b1 (i *! HD.block_len a) (HD.block_len a) in let bl2 = sub b2 (i *! HD.block_len a) (HD.block_len a) in let bl3 = sub b3 (i *! HD.block_len a) (HD.block_len a) in let bl4 = sub b4 (i *! HD.block_len a) (HD.block_len a) in let bl5 = sub b5 (i *! HD.block_len a) (HD.block_len a) in let bl6 = sub b6 (i *! HD.block_len a) (HD.block_len a) in let bl7 = sub b7 (i *! HD.block_len a) (HD.block_len a) in let mb = NTup.ntup8 (bl0, (bl1, (bl2, (bl3, (bl4, (bl5, (bl6, bl7))))))) in let h1 = ST.get () in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "Hacl.Spec.SHA2.Vec.lanes", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_Division", "Spec.Hash.Definitions.block_length", "Prims.unit", "Lib.NTuple.eq_intro", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8", "Hacl.Hash.Definitions.block_len", "Lib.MultiBuffer.as_seq_multi", "Hacl.Spec.SHA2.Vec.get_multiblock_spec", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.NTuple.ntuple", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.NTuple.ntup1", "Lib.Buffer.lbuffer", "Lib.Buffer.sub", "Lib.IntTypes.op_Star_Bang", "Lib.NTuple.tup1", "Lib.NTuple.ntup4", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Lib.NTuple.tup4", "Lib.NTuple.ntup8", "Lib.NTuple.tup8", "Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 200" let emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); () #pop-options noextract let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in hsub noextract let emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 700" let emit8 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 result in assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a)); copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a)); copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a)); copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a)); assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a)); assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a)); assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup8 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, (as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7)))))))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+| loc b7) h0 h1); assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf)); emit8_lemma #a #m (as_seq h0 hbuf); loc_multi8 result; assert (modifies_multi result h0 h1); () #pop-options inline_for_extraction noextract val emit: #a:sha2_alg -> #m:m_spec{is_supported a m} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit #a #m hbuf result = match lanes a m with | 1 -> emit1 #a #m hbuf result | 4 -> emit4 #a #m hbuf result | 8 -> emit8 #a #m hbuf result noextract let preserves_disjoint_multi #lanes #len #len' (b:multibuf lanes len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint_multi b x ==> disjoint_multi r x) val lemma_len_lt_max_a_fits_size_t: a:sha2_alg -> len:size_t -> Lemma (v len `less_than_max_input_length` a) let lemma_len_lt_max_a_fits_size_t a len = match a with | SHA2_224 | SHA2_256 -> Math.Lemmas.pow2_lt_compat 61 32 | SHA2_384 | SHA2_512 -> Math.Lemmas.pow2_lt_compat 125 32 inline_for_extraction noextract let get_multiblock_t (a:sha2_alg) (m:m_spec) = len:size_t -> b:multibuf (lanes a m) len -> i:size_t{v i < v len / block_length a} -> Stack (multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live_multi h b) (ensures fun h0 r h1 -> h0 == h1 /\ live_multi h1 r /\ preserves_disjoint_multi b r /\ (lemma_len_lt_max_a_fits_size_t a len; as_seq_multi h1 r == SpecVec.get_multiblock_spec (v len) (as_seq_multi h0 b) (v i))) inline_for_extraction noextract val get_multiblock: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multiblock_t a m
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_multiblock: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multiblock_t a m
[]
Hacl.Impl.SHA2.Core.get_multiblock
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.SHA2.Core.get_multiblock_t a m
{ "end_col": 6, "end_line": 840, "start_col": 2, "start_line": 807 }
Prims.Tot
val emit8_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a)
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in hsub
val emit8_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) let emit8_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) =
false
null
false
let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub:multiseq 8 (hash_length a) = ntup8 (h0, (h1, (h2, (h3, (h4, (h5, (h6, h7))))))) in hsub
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Sequence.lseq", "Lib.IntTypes.uint8", "FStar.Mul.op_Star", "Spec.Hash.Definitions.word_length", "Hacl.Spec.SHA2.Vec.multiseq", "Spec.Hash.Definitions.hash_length", "Lib.NTuple.ntup8", "FStar.Seq.Properties.lseq", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.l_and", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.op_Multiply", "Prims.op_Addition", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.sub" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 200" let emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); () #pop-options noextract let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a)
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emit8_spec (#a: sha2_alg) (#m: m_spec{lanes a m == 8}) (hseq: LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a)
[]
Hacl.Impl.SHA2.Core.emit8_spec
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hseq: Lib.Sequence.lseq Lib.IntTypes.uint8 ((Hacl.Spec.SHA2.Vec.lanes a m * 8) * Spec.Hash.Definitions.word_length a) -> Hacl.Spec.SHA2.Vec.multiseq (Hacl.Spec.SHA2.Vec.lanes a m) (Spec.Hash.Definitions.hash_length a)
{ "end_col": 6, "end_line": 707, "start_col": 2, "start_line": 697 }
Prims.Tot
val get_multilast: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multilast_t a m
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 get_multilast #a #m len b = lemma_len_lt_max_a_fits_size_t a len; let h0 = ST.get() in let rem = len %. HD.block_len a in assert (v (len -! rem) == v len - v rem); match lanes a m with | 1 -> let b0 = NTup.tup1 b in let b' = sub b0 (len -! rem) rem in let mb' = NTup.ntup1 b' in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb') (SpecVec.get_multilast_spec #a #m (v len) (as_seq_multi h0 b)); mb' | 4 -> let (b0,(b1,(b2,b3))) = NTup.tup4 b in let bl0 = sub b0 (len -! rem) rem in let bl1 = sub b1 (len -! rem) rem in let bl2 = sub b2 (len -! rem) rem in let bl3 = sub b3 (len -! rem) rem in let mb = NTup.ntup4 (bl0, (bl1, (bl2, bl3))) in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multilast_spec #a #m (v len) (as_seq_multi h0 b)); mb | 8 -> let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let bl0 = sub b0 (len -! rem) (rem) in let bl1 = sub b1 (len -! rem) (rem) in let bl2 = sub b2 (len -! rem) (rem) in let bl3 = sub b3 (len -! rem) (rem) in let bl4 = sub b4 (len -! rem) (rem) in let bl5 = sub b5 (len -! rem) (rem) in let bl6 = sub b6 (len -! rem) (rem) in let bl7 = sub b7 (len -! rem) (rem) in let mb = NTup.ntup8 (bl0, (bl1, (bl2, (bl3, (bl4, (bl5, (bl6, bl7))))))) in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multilast_spec #a #m (v len) (as_seq_multi h0 b)); mb
val get_multilast: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multilast_t a m let get_multilast #a #m len b =
false
null
false
lemma_len_lt_max_a_fits_size_t a len; let h0 = ST.get () in let rem = len %. HD.block_len a in assert (v (len -! rem) == v len - v rem); match lanes a m with | 1 -> let b0 = NTup.tup1 b in let b' = sub b0 (len -! rem) rem in let mb' = NTup.ntup1 b' in let h1 = ST.get () in NTup.eq_intro (as_seq_multi h1 mb') (SpecVec.get_multilast_spec #a #m (v len) (as_seq_multi h0 b)); mb' | 4 -> let b0, (b1, (b2, b3)) = NTup.tup4 b in let bl0 = sub b0 (len -! rem) rem in let bl1 = sub b1 (len -! rem) rem in let bl2 = sub b2 (len -! rem) rem in let bl3 = sub b3 (len -! rem) rem in let mb = NTup.ntup4 (bl0, (bl1, (bl2, bl3))) in let h1 = ST.get () in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multilast_spec #a #m (v len) (as_seq_multi h0 b)); mb | 8 -> let b0, (b1, (b2, (b3, (b4, (b5, (b6, b7)))))) = NTup.tup8 b in let bl0 = sub b0 (len -! rem) (rem) in let bl1 = sub b1 (len -! rem) (rem) in let bl2 = sub b2 (len -! rem) (rem) in let bl3 = sub b3 (len -! rem) (rem) in let bl4 = sub b4 (len -! rem) (rem) in let bl5 = sub b5 (len -! rem) (rem) in let bl6 = sub b6 (len -! rem) (rem) in let bl7 = sub b7 (len -! rem) (rem) in let mb = NTup.ntup8 (bl0, (bl1, (bl2, (bl3, (bl4, (bl5, (bl6, bl7))))))) in let h1 = ST.get () in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multilast_spec #a #m (v len) (as_seq_multi h0 b)); mb
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Hacl.Spec.SHA2.Vec.is_supported", "Lib.IntTypes.size_t", "Lib.MultiBuffer.multibuf", "Hacl.Spec.SHA2.Vec.lanes", "Prims.unit", "Lib.NTuple.eq_intro", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.op_Percent_Dot", "Hacl.Hash.Definitions.block_len", "Lib.MultiBuffer.as_seq_multi", "Hacl.Spec.SHA2.Vec.get_multilast_spec", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.NTuple.ntuple", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.mod", "Lib.NTuple.ntup1", "Lib.Buffer.lbuffer", "Lib.Buffer.sub", "Lib.IntTypes.op_Subtraction_Bang", "Lib.NTuple.tup1", "Lib.NTuple.ntup4", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Lib.NTuple.tup4", "Lib.NTuple.ntup8", "Lib.NTuple.tup8", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Subtraction", "Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 200" let emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); () #pop-options noextract let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in hsub noextract let emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 700" let emit8 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 result in assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a)); copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a)); copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a)); copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a)); assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a)); assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a)); assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup8 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, (as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7)))))))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+| loc b7) h0 h1); assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf)); emit8_lemma #a #m (as_seq h0 hbuf); loc_multi8 result; assert (modifies_multi result h0 h1); () #pop-options inline_for_extraction noextract val emit: #a:sha2_alg -> #m:m_spec{is_supported a m} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit #a #m hbuf result = match lanes a m with | 1 -> emit1 #a #m hbuf result | 4 -> emit4 #a #m hbuf result | 8 -> emit8 #a #m hbuf result noextract let preserves_disjoint_multi #lanes #len #len' (b:multibuf lanes len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint_multi b x ==> disjoint_multi r x) val lemma_len_lt_max_a_fits_size_t: a:sha2_alg -> len:size_t -> Lemma (v len `less_than_max_input_length` a) let lemma_len_lt_max_a_fits_size_t a len = match a with | SHA2_224 | SHA2_256 -> Math.Lemmas.pow2_lt_compat 61 32 | SHA2_384 | SHA2_512 -> Math.Lemmas.pow2_lt_compat 125 32 inline_for_extraction noextract let get_multiblock_t (a:sha2_alg) (m:m_spec) = len:size_t -> b:multibuf (lanes a m) len -> i:size_t{v i < v len / block_length a} -> Stack (multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live_multi h b) (ensures fun h0 r h1 -> h0 == h1 /\ live_multi h1 r /\ preserves_disjoint_multi b r /\ (lemma_len_lt_max_a_fits_size_t a len; as_seq_multi h1 r == SpecVec.get_multiblock_spec (v len) (as_seq_multi h0 b) (v i))) inline_for_extraction noextract val get_multiblock: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multiblock_t a m let get_multiblock #a #m len b i = lemma_len_lt_max_a_fits_size_t a len; let h0 = ST.get() in match lanes a m with | 1 -> let b0 = NTup.tup1 b in let b' = sub b0 (i *! HD.block_len a) (HD.block_len a) in let mb' = NTup.ntup1 b' in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb') (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb' | 4 -> let (b0,(b1,(b2,b3))) = NTup.tup4 b in let bl0 = sub b0 (i *! HD.block_len a) (HD.block_len a) in let bl1 = sub b1 (i *! HD.block_len a) (HD.block_len a) in let bl2 = sub b2 (i *! HD.block_len a) (HD.block_len a) in let bl3 = sub b3 (i *! HD.block_len a) (HD.block_len a) in let mb = NTup.ntup4 (bl0, (bl1, (bl2, bl3))) in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb | 8 -> let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let bl0 = sub b0 (i *! HD.block_len a) (HD.block_len a) in let bl1 = sub b1 (i *! HD.block_len a) (HD.block_len a) in let bl2 = sub b2 (i *! HD.block_len a) (HD.block_len a) in let bl3 = sub b3 (i *! HD.block_len a) (HD.block_len a) in let bl4 = sub b4 (i *! HD.block_len a) (HD.block_len a) in let bl5 = sub b5 (i *! HD.block_len a) (HD.block_len a) in let bl6 = sub b6 (i *! HD.block_len a) (HD.block_len a) in let bl7 = sub b7 (i *! HD.block_len a) (HD.block_len a) in let mb = NTup.ntup8 (bl0, (bl1, (bl2, (bl3, (bl4, (bl5, (bl6, bl7))))))) in let h1 = ST.get() in NTup.eq_intro (as_seq_multi h1 mb) (SpecVec.get_multiblock_spec #a #m (v len) (as_seq_multi h0 b) (v i)); mb inline_for_extraction noextract let get_multilast_t (a:sha2_alg) (m:m_spec) = len:size_t -> b:multibuf (lanes a m) len -> Stack (multibuf (lanes a m) (len %. HD.block_len a)) (requires fun h -> live_multi h b) (ensures fun h0 r h1 -> h0 == h1 /\ live_multi h1 r /\ preserves_disjoint_multi b r /\ (lemma_len_lt_max_a_fits_size_t a len; as_seq_multi h1 r == SpecVec.get_multilast_spec #a #m (v len) (as_seq_multi h0 b))) inline_for_extraction noextract val get_multilast: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multilast_t a m #push-options "--z3rlimit 300"
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_multilast: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multilast_t a m
[]
Hacl.Impl.SHA2.Core.get_multilast
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.SHA2.Core.get_multilast_t a m
{ "end_col": 6, "end_line": 892, "start_col": 2, "start_line": 857 }
FStar.HyperStack.ST.Stack
val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); ()
val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit4 #a #m hbuf result =
true
null
false
let h0 = ST.get () in let b0, (b1, (b2, b3)) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get () in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); ()
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.size", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.word_len", "Lib.MultiBuffer.multibuf", "Hacl.Hash.Definitions.hash_len", "Prims.unit", "Prims._assert", "Lib.MultiBuffer.modifies_multi", "Lib.MultiBuffer.loc_multi4", "Hacl.Impl.SHA2.Core.emit4_lemma", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.eq2", "Lib.NTuple.ntuple", "FStar.Seq.Properties.lseq", "Spec.Hash.Definitions.hash_length", "Lib.MultiBuffer.as_seq_multi", "Hacl.Impl.SHA2.Core.emit4_spec", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "Lib.NTuple.eq_intro", "Lib.IntTypes.v", "Lib.NTuple.ntup4", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.seq", "Prims.l_or", "Prims.l_and", "Prims.nat", "FStar.Seq.Base.length", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "FStar.Mul.op_Star", "Spec.Hash.Definitions.word_length", "Prims.op_Addition", "Prims.l_Forall", "Prims.op_LessThan", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.sub", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.copy", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.sub", "Lib.Buffer.disjoint", "Lib.NTuple.tup4" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
[]
Hacl.Impl.SHA2.Core.emit4
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hbuf: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Lib.IntTypes.size (Hacl.Spec.SHA2.Vec.lanes a m) *! 8ul *! Hacl.Hash.Definitions.word_len a ) -> result: Lib.MultiBuffer.multibuf (Hacl.Spec.SHA2.Vec.lanes a m) (Hacl.Hash.Definitions.hash_len a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 4, "end_line": 689, "start_col": 29, "start_line": 665 }
FStar.HyperStack.ST.Stack
val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib))
val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws =
true
null
false
let h0 = ST.get () in let b = ib.(| 0 |) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get () in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get () in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib))
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.MultiBuffer.multibuf", "Hacl.Hash.Definitions.block_len", "Hacl.Impl.SHA2.Core.ws_t", "Prims._assert", "Lib.Sequence.lseq", "Hacl.Spec.SHA2.Vec.element_t", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t", "Hacl.Spec.SHA2.Vec.load_blocks", "Lib.MultiBuffer.as_seq_multi", "Prims.unit", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.SHA2.Core.load_blocks_spec1", "Hacl.Impl.SHA2.Core.load_blocks_spec1_lemma", "Lib.Sequence.eq_intro", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.SHA2.Core.set_wsi", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.MultiBuffer.op_Lens_Access", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
[]
Hacl.Impl.SHA2.Core.load_blocks1
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.MultiBuffer.multibuf (Hacl.Spec.SHA2.Vec.lanes a m) (Hacl.Hash.Definitions.block_len a) -> ws: Hacl.Impl.SHA2.Core.ws_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 67, "end_line": 125, "start_col": 30, "start_line": 99 }
Prims.Tot
val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1)
val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m let load_last4 #a #m totlen_buf len b fin last =
false
null
false
let h0 = ST.get () in let b0, (b1, (b2, b3)) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get () in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let l00, l01 = load_last_blocks #a totlen_buf len b0 fin last0 in let l10, l11 = load_last_blocks #a totlen_buf len b1 fin last1 in let l20, l21 = load_last_blocks #a totlen_buf len b2 fin last2 in let l30, l31 = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get () in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Spec.Hash.Definitions.len_len", "Lib.IntTypes.size_t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.block_length", "Lib.MultiBuffer.multibuf", "Prims.l_or", "Prims.eq2", "Lib.IntTypes.range", "Prims.op_disEquality", "FStar.Mul.op_Star", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.block_len", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "FStar.Pervasives.reveal_opaque", "Lib.Sequence.lseq", "Spec.Hash.Definitions.len_length", "Prims.nat", "Prims.op_GreaterThanOrEqual", "Hacl.Spec.SHA2.Vec.multiseq", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.SHA2.Vec.load_last", "Prims._assert", "Lib.MultiBuffer.live_multi", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Buffer.MUT", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.NTuple.eq_intro", "FStar.Seq.Properties.lseq", "Lib.MultiBuffer.as_seq_multi", "Lib.NTuple.ntup4", "Lib.Buffer.as_seq", "Hacl.Spec.SHA2.Vec.load_last_blocks", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Hacl.Impl.SHA2.Core.load_last_blocks", "Lib.Sequence.eq_intro", "Lib.Sequence.create", "Lib.IntTypes.u8", "Lib.Buffer.disjoint", "Lib.IntTypes.mul", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Lib.NTuple.tup4" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 350, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m
[]
Hacl.Impl.SHA2.Core.load_last4
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.SHA2.Core.load_last_t a m
{ "end_col": 12, "end_line": 474, "start_col": 48, "start_line": 439 }
FStar.HyperStack.ST.Stack
val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); ()
val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks8 #a #m ib ws =
true
null
false
let h0 = ST.get () in let b0, (b1, (b2, (b3, (b4, (b5, (b6, b7)))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get () in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get () in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); ()
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.MultiBuffer.multibuf", "Hacl.Hash.Definitions.block_len", "Hacl.Impl.SHA2.Core.ws_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.unit", "Prims._assert", "Lib.Sequence.lseq", "Hacl.Spec.SHA2.Vec.element_t", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t", "Hacl.Spec.SHA2.Vec.load_blocks", "Lib.MultiBuffer.as_seq_multi", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.SHA2.Core.load_blocks_spec8", "Hacl.Impl.SHA2.Core.load_blocks_spec8_lemma", "Lib.Sequence.eq_intro", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.SHA2.Core.set_wsi", "FStar.Pervasives.Native.tuple2", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.NTuple.tup8" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
[]
Hacl.Impl.SHA2.Core.load_blocks8
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.MultiBuffer.multibuf (Hacl.Spec.SHA2.Vec.lanes a m) (Hacl.Hash.Definitions.block_len a) -> ws: Hacl.Impl.SHA2.Core.ws_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 4, "end_line": 277, "start_col": 30, "start_line": 250 }
FStar.HyperStack.ST.Stack
val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); ()
val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks4 #a #m ib ws =
true
null
false
let h0 = ST.get () in let b0, (b1, (b2, b3)) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get () in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get () in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); ()
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.eq2", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.MultiBuffer.multibuf", "Hacl.Hash.Definitions.block_len", "Hacl.Impl.SHA2.Core.ws_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.unit", "Prims._assert", "Lib.Sequence.lseq", "Hacl.Spec.SHA2.Vec.element_t", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t", "Hacl.Spec.SHA2.Vec.load_blocks", "Lib.MultiBuffer.as_seq_multi", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.SHA2.Core.load_blocks_spec4", "Hacl.Impl.SHA2.Core.load_blocks_spec4_lemma", "Lib.Sequence.eq_intro", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.SHA2.Core.set_wsi", "FStar.Pervasives.Native.tuple2", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.NTuple.tup4" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b))
[]
Hacl.Impl.SHA2.Core.load_blocks4
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.MultiBuffer.multibuf (Hacl.Spec.SHA2.Vec.lanes a m) (Hacl.Hash.Definitions.block_len a) -> ws: Hacl.Impl.SHA2.Core.ws_t a m -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 4, "end_line": 199, "start_col": 30, "start_line": 172 }
FStar.HyperStack.ST.Stack
val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 emit8 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 result in assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a)); copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a)); copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a)); copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a)); assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a)); assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a)); assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup8 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, (as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7)))))))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+| loc b7) h0 h1); assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf)); emit8_lemma #a #m (as_seq h0 hbuf); loc_multi8 result; assert (modifies_multi result h0 h1); ()
val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit8 #a #m hbuf result =
true
null
false
let h0 = ST.get () in let b0, (b1, (b2, (b3, (b4, (b5, (b6, b7)))))) = NTup.tup8 result in assert (internally_disjoint8 b0 b1 b2 b3 b4 b5 b6 b7); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get () in assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); copy b4 (sub hbuf (32ul *! HD.word_len a) (HD.hash_len a)); copy b5 (sub hbuf (40ul *! HD.word_len a) (HD.hash_len a)); copy b6 (sub hbuf (48ul *! HD.word_len a) (HD.hash_len a)); copy b7 (sub hbuf (56ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get () in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); assert (as_seq h1 b4 == LSeq.sub (as_seq h0 hbuf) (32 * word_length a) (hash_length a)); assert (as_seq h1 b5 == LSeq.sub (as_seq h0 hbuf) (40 * word_length a) (hash_length a)); assert (as_seq h1 b6 == LSeq.sub (as_seq h0 hbuf) (48 * word_length a) (hash_length a)); assert (as_seq h1 b7 == LSeq.sub (as_seq h0 hbuf) (56 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup8 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, (as_seq h1 b3, (as_seq h1 b4, (as_seq h1 b5, (as_seq h1 b6, as_seq h1 b7)))))))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3 |+| loc b4 |+| loc b5 |+| loc b6 |+| loc b7) h0 h1); assert (as_seq_multi h1 result == emit8_spec #a #m (as_seq h0 hbuf)); emit8_lemma #a #m (as_seq h0 hbuf); loc_multi8 result; assert (modifies_multi result h0 h1); ()
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.size", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.word_len", "Lib.MultiBuffer.multibuf", "Hacl.Hash.Definitions.hash_len", "Prims.unit", "Prims._assert", "Lib.MultiBuffer.modifies_multi", "Lib.MultiBuffer.loc_multi8", "Hacl.Impl.SHA2.Core.emit8_lemma", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.eq2", "Lib.NTuple.ntuple", "FStar.Seq.Properties.lseq", "Spec.Hash.Definitions.hash_length", "Lib.MultiBuffer.as_seq_multi", "Hacl.Impl.SHA2.Core.emit8_spec", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "Lib.NTuple.eq_intro", "Lib.IntTypes.v", "Lib.NTuple.ntup8", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.seq", "Prims.l_or", "Prims.l_and", "Prims.nat", "FStar.Seq.Base.length", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "FStar.Mul.op_Star", "Spec.Hash.Definitions.word_length", "Prims.op_Addition", "Prims.l_Forall", "Prims.op_LessThan", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.sub", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.copy", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.sub", "Lib.MultiBuffer.internally_disjoint8", "Lib.NTuple.tup8" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m #push-options "--z3rlimit 600" let load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m let load_last #a #m totlen_buf len b fin last = match lanes a m with | 1 -> load_last1 #a #m totlen_buf len b fin last | 4 -> load_last4 #a #m totlen_buf len b fin last | 8 -> load_last8 #a #m totlen_buf len b fin last inline_for_extraction noextract val transpose_state4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state4 (as_seq h0 st)) let transpose_state4 #a #m st = let (st0',st1',st2',st3') = VecTranspose.transpose4x4 (st.(0ul),st.(1ul),st.(2ul),st.(3ul)) in let (st4',st5',st6',st7') = VecTranspose.transpose4x4 (st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st4' st1' st5' st2' st6' st3' st7' inline_for_extraction noextract val transpose_state8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state8 (as_seq h0 st)) let transpose_state8 #a #m st = let (st0',st1',st2',st3',st4',st5',st6',st7') = VecTranspose.transpose8x8 (st.(0ul),st.(1ul),st.(2ul),st.(3ul),st.(4ul),st.(5ul),st.(6ul),st.(7ul)) in create8 st st0' st1' st2' st3' st4' st5' st6' st7' inline_for_extraction noextract val transpose_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == SpecVec.transpose_state (as_seq h0 st)) let transpose_state #a #m st = match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st inline_for_extraction noextract val store_state: #a:sha2_alg -> #m:m_spec{is_supported a m} -> st:state_t a m -> hbuf:lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> Stack unit (requires fun h -> live h hbuf /\ live h st /\ disjoint hbuf st /\ as_seq h hbuf == LSeq.create (lanes a m * 8 * word_length a) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc st |+| loc hbuf) h0 h1 /\ as_seq h1 hbuf == SpecVec.store_state #a #m (as_seq h0 st)) let store_state #a #m st hbuf = transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st noextract let emit1_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub noextract let emit1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit1_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> hbuf:lbuffer uint8 (8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) let emit1 #a #m hbuf result = let h0 = ST.get() in copy result.(|0|) (sub hbuf 0ul (HD.hash_len a)); let h1 = ST.get() in Lib.NTuple.eq_intro (as_seq_multi h1 result) (emit1_spec #a #m (as_seq h0 hbuf)); emit1_lemma #a #m (as_seq h0 hbuf); assert (modifies_multi result h0 h1) noextract let emit4_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let hsub : multiseq 4 (hash_length a) = ntup4 (h0,(h1,(h2,h3))) in hsub noextract let emit4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit4_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf)) #push-options "--z3rlimit 200" let emit4 #a #m hbuf result = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 result in assert (disjoint b0 b1); assert (disjoint b0 b2); assert (disjoint b0 b3); assert (disjoint b1 b2); assert (disjoint b1 b3); assert (disjoint b2 b3); copy b0 (sub hbuf 0ul (HD.hash_len a)); copy b1 (sub hbuf (8ul *! HD.word_len a) (HD.hash_len a)); copy b2 (sub hbuf (16ul *! HD.word_len a) (HD.hash_len a)); copy b3 (sub hbuf (24ul *! HD.word_len a) (HD.hash_len a)); let h1 = ST.get() in assert (as_seq h1 b0 == LSeq.sub (as_seq h0 hbuf) 0 (hash_length a)); assert (as_seq h1 b1 == LSeq.sub (as_seq h0 hbuf) (8 * word_length a) (hash_length a)); assert (as_seq h1 b2 == LSeq.sub (as_seq h0 hbuf) (16 * word_length a) (hash_length a)); assert (as_seq h1 b3 == LSeq.sub (as_seq h0 hbuf) (24 * word_length a) (hash_length a)); NTup.eq_intro (as_seq_multi h1 result) (NTup.ntup4 (as_seq h1 b0, (as_seq h1 b1, (as_seq h1 b2, as_seq h1 b3)))); assert (modifies (loc b0 |+| loc b1 |+| loc b2 |+| loc b3) h0 h1); assert (as_seq_multi h1 result == emit4_spec #a #m (as_seq h0 hbuf)); emit4_lemma #a #m (as_seq h0 hbuf); loc_multi4 result; assert (modifies_multi result h0 h1); () #pop-options noextract let emit8_spec (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : multiseq (lanes a m) (hash_length a) = let open Lib.Sequence in let h0 = sub hseq 0 (hash_length a) in let h1 = sub hseq (8 * word_length a) (hash_length a) in let h2 = sub hseq (16 * word_length a) (hash_length a) in let h3 = sub hseq (24 * word_length a) (hash_length a) in let h4 = sub hseq (32 * word_length a) (hash_length a) in let h5 = sub hseq (40 * word_length a) (hash_length a) in let h6 = sub hseq (48 * word_length a) (hash_length a) in let h7 = sub hseq (56 * word_length a) (hash_length a) in let hsub : multiseq 8 (hash_length a) = ntup8 (h0,(h1,(h2,(h3,(h4,(h5,(h6,h7))))))) in hsub noextract let emit8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (hseq:LSeq.lseq uint8 (lanes a m * 8 * word_length a)) : Lemma (emit8_spec #a #m hseq == SpecVec.emit #a #m hseq) = Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq) inline_for_extraction noextract val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 700, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emit8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> hbuf: lbuffer uint8 (size (lanes a m) *! 8ul *! HD.word_len a) -> result:multibuf (lanes a m) (HD.hash_len a) -> Stack unit (requires fun h -> live_multi h result /\ live h hbuf /\ internally_disjoint result /\ disjoint_multi result hbuf) (ensures fun h0 _ h1 -> modifies_multi result h0 h1 /\ as_seq_multi h1 result == SpecVec.emit #a #m (as_seq h0 hbuf))
[]
Hacl.Impl.SHA2.Core.emit8
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hbuf: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Lib.IntTypes.size (Hacl.Spec.SHA2.Vec.lanes a m) *! 8ul *! Hacl.Hash.Definitions.word_len a ) -> result: Lib.MultiBuffer.multibuf (Hacl.Spec.SHA2.Vec.lanes a m) (Hacl.Hash.Definitions.hash_len a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 4, "end_line": 758, "start_col": 29, "start_line": 728 }
Prims.Tot
val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m
[ { "abbrev": true, "full_module": "Hacl.Hash.Definitions", "short_module": "HD" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.IntVector.Transpose", "short_module": "VecTranspose" }, { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": true, "full_module": "Lib.NTuple", "short_module": "NTup" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.MultiBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.NTuple", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": 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 load_last8 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get() in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1) h0 h2); let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let (l40,l41) = load_last_blocks #a totlen_buf len b4 fin last4 in let (l50,l51) = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let (l60,l61) = load_last_blocks #a totlen_buf len b6 fin last6 in let (l70,l71) = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get() in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1)
val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m let load_last8 #a #m totlen_buf len b fin last =
false
null
false
let h0 = ST.get () in let b0, (b1, (b2, (b3, (b4, (b5, (b6, b7)))))) = NTup.tup8 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let last4 = sub last (8ul *! HD.block_len a) (2ul *! HD.block_len a) in let last5 = sub last (10ul *! HD.block_len a) (2ul *! HD.block_len a) in let last6 = sub last (12ul *! HD.block_len a) (2ul *! HD.block_len a) in let last7 = sub last (14ul *! HD.block_len a) (2ul *! HD.block_len a) in assert (internally_disjoint8 last0 last1 last2 last3 last4 last5 last6 last7); let h1 = ST.get () in assert (h0 == h1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last4) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last5) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last6) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last7) (LSeq.create (2 * block_length a) (u8 0)); let l00, l01 = load_last_blocks #a totlen_buf len b0 fin last0 in let l10, l11 = load_last_blocks #a totlen_buf len b1 fin last1 in let h2 = ST.get () in assert (modifies (loc last0 |+| loc last1) h0 h2); let l20, l21 = load_last_blocks #a totlen_buf len b2 fin last2 in let l30, l31 = load_last_blocks #a totlen_buf len b3 fin last3 in let h2 = ST.get () in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h2); let l40, l41 = load_last_blocks #a totlen_buf len b4 fin last4 in let l50, l51 = load_last_blocks #a totlen_buf len b5 fin last5 in let h2 = ST.get () in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5) h0 h2); let l60, l61 = load_last_blocks #a totlen_buf len b6 fin last6 in let l70, l71 = load_last_blocks #a totlen_buf len b7 fin last7 in let h3 = ST.get () in assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3 |+| loc last4 |+| loc last5 |+| loc last6 |+| loc last7) h0 h3); assert (modifies (loc last) h0 h3); let mb0:multibuf (lanes a m) (HD.block_len a) = ntup8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))) in ntup8_lemma #_ #8 (l00, (l10, (l20, (l30, (l40, (l50, (l60, l70))))))); ntup8_lemma #_ #8 (l01, (l11, (l21, (l31, (l41, (l51, (l61, l71))))))); assert (live_multi h3 mb0); assert (live_multi h3 mb1); NTup.eq_intro (as_seq_multi h3 mb0) (ntup8 (as_seq h3 l00, (as_seq h3 l10, (as_seq h3 l20, (as_seq h3 l30, (as_seq h3 l40, (as_seq h3 l50, (as_seq h3 l60, (as_seq h3 l70))))))))); NTup.eq_intro (as_seq_multi h3 mb1) (ntup8 (as_seq h3 l01, (as_seq h3 l11, (as_seq h3 l21, (as_seq h3 l31, (as_seq h3 l41, (as_seq h3 l51, (as_seq h3 l61, (as_seq h3 l71))))))))); assert ((as_seq_multi h3 mb0, as_seq_multi h3 mb1) == SpecVec.load_last8 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1)
{ "checked_file": "Hacl.Impl.SHA2.Core.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NTuple.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.Transpose.fsti.checked", "Lib.IntVector.Serialize.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Impl.SHA2.Types.fst.checked", "Hacl.Hash.Definitions.fst.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.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Core.fst" }
[ "total" ]
[ "Spec.Hash.Definitions.sha2_alg", "Hacl.Spec.SHA2.Vec.m_spec", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Hacl.Spec.SHA2.Vec.lanes", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Spec.Hash.Definitions.len_len", "Lib.IntTypes.size_t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.block_length", "Lib.MultiBuffer.multibuf", "Prims.l_or", "Prims.eq2", "Lib.IntTypes.range", "Prims.op_disEquality", "FStar.Mul.op_Star", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "FStar.UInt32.__uint_to_t", "Hacl.Hash.Definitions.block_len", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "FStar.Pervasives.reveal_opaque", "Lib.Sequence.lseq", "Spec.Hash.Definitions.len_length", "Prims.nat", "Prims.op_GreaterThanOrEqual", "Hacl.Spec.SHA2.Vec.multiseq", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.SHA2.Vec.load_last", "Prims._assert", "Lib.MultiBuffer.as_seq_multi", "Hacl.Spec.SHA2.Vec.load_last8", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.NTuple.eq_intro", "FStar.Seq.Properties.lseq", "Lib.NTuple.ntup8", "Lib.MultiBuffer.live_multi", "Lib.NTuple.ntup8_lemma", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Buffer.op_Bar_Plus_Bar", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Hacl.Impl.SHA2.Core.load_last_blocks", "Lib.Sequence.eq_intro", "Lib.Sequence.create", "Lib.IntTypes.u8", "Lib.MultiBuffer.internally_disjoint8", "Lib.IntTypes.mul", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Lib.NTuple.tup8" ]
[]
module Hacl.Impl.SHA2.Core open FStar.Mul open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.NTuple open Lib.Buffer open Lib.IntVector open Lib.MultiBuffer open Spec.Hash.Definitions //open Hacl.Hash.Definitions // <- defines as_seq which clashes with Lib.Buffer.as_seq open Hacl.Spec.SHA2.Vec module ST = FStar.HyperStack.ST module NTup = Lib.NTuple module SpecVec = Hacl.Spec.SHA2.Vec module VecTranspose = Lib.IntVector.Transpose module LSeq = Lib.Sequence module HD = Hacl.Hash.Definitions (* Force ordering in dependency analysis so that monomorphizations are inserted into the Types module first. *) let _ = Hacl.Impl.SHA2.Types.uint8_8p #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50" unfold let state_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 8ul unfold let block_t (a:sha2_alg) = lbuffer uint8 (HD.block_len a) inline_for_extraction noextract let ws_t (a:sha2_alg) (m:m_spec) = lbuffer (element_t a m) 16ul inline_for_extraction noextract val set_wsi: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> i:size_t{v i < 16} -> b:lbuffer uint8 (HD.block_len a) -> bi:size_t{v bi < 16 / (lanes a m)} -> Stack unit (requires fun h -> live h b /\ live h ws /\ disjoint b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == LSeq.upd (as_seq h0 ws) (v i) (SpecVec.load_elementi #a #m (as_seq h0 b) (v bi))) let set_wsi #a #m ws i b bi = [@inline_let] let l = lanes a m in ws.(i) <- vec_load_be (word_t a) l (sub b (bi *! size l *! HD.word_len a) (size l *! HD.word_len a)) noextract let load_blocks_spec1 (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : ws_spec a m = let b = b.(|0|) in let ws0 = SpecVec.load_elementi b 0 in let ws1 = SpecVec.load_elementi b 1 in let ws2 = SpecVec.load_elementi b 2 in let ws3 = SpecVec.load_elementi b 3 in let ws4 = SpecVec.load_elementi b 4 in let ws5 = SpecVec.load_elementi b 5 in let ws6 = SpecVec.load_elementi b 6 in let ws7 = SpecVec.load_elementi b 7 in let ws8 = SpecVec.load_elementi b 8 in let ws9 = SpecVec.load_elementi b 9 in let ws10 = SpecVec.load_elementi b 10 in let ws11 = SpecVec.load_elementi b 11 in let ws12 = SpecVec.load_elementi b 12 in let ws13 = SpecVec.load_elementi b 13 in let ws14 = SpecVec.load_elementi b 14 in let ws15 = SpecVec.load_elementi b 15 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec1_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 1}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec1 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec1 b) #push-options "--z3rlimit 100" inline_for_extraction noextract val load_blocks1: #a:sha2_alg -> #m:m_spec{lanes a m == 1} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks1 #a #m ib ws = let h0 = ST.get() in let b = ib.(|0|) in set_wsi ws 0ul b 0ul; set_wsi ws 1ul b 1ul; set_wsi ws 2ul b 2ul; set_wsi ws 3ul b 3ul; set_wsi ws 4ul b 4ul; set_wsi ws 5ul b 5ul; set_wsi ws 6ul b 6ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b 7ul; set_wsi ws 8ul b 8ul; set_wsi ws 9ul b 9ul; set_wsi ws 10ul b 10ul; set_wsi ws 11ul b 11ul; set_wsi ws 12ul b 12ul; set_wsi ws 13ul b 13ul; set_wsi ws 14ul b 14ul; set_wsi ws 15ul b 15ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec1 (as_seq_multi h0 ib)); load_blocks_spec1_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec1 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)) #pop-options noextract let load_blocks_spec4 (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b0 1 in let ws5 = SpecVec.load_elementi b1 1 in let ws6 = SpecVec.load_elementi b2 1 in let ws7 = SpecVec.load_elementi b3 1 in let ws8 = SpecVec.load_elementi b0 2 in let ws9 = SpecVec.load_elementi b1 2 in let ws10 = SpecVec.load_elementi b2 2 in let ws11 = SpecVec.load_elementi b3 2 in let ws12 = SpecVec.load_elementi b0 3 in let ws13 = SpecVec.load_elementi b1 3 in let ws14 = SpecVec.load_elementi b2 3 in let ws15 = SpecVec.load_elementi b3 3 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec4_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 4}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec4 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b) inline_for_extraction noextract val load_blocks4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks4 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b0 1ul; set_wsi ws 5ul b1 1ul; set_wsi ws 6ul b2 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b3 1ul; set_wsi ws 8ul b0 2ul; set_wsi ws 9ul b1 2ul; set_wsi ws 10ul b2 2ul; set_wsi ws 11ul b3 2ul; set_wsi ws 12ul b0 3ul; set_wsi ws 13ul b1 3ul; set_wsi ws 14ul b2 3ul; set_wsi ws 15ul b3 3ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec4 (as_seq_multi h0 ib)); load_blocks_spec4_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec4 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options noextract let load_blocks_spec8 (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : ws_spec a m = let b0 = b.(|0|) in let b1 = b.(|1|) in let b2 = b.(|2|) in let b3 = b.(|3|) in let b4 = b.(|4|) in let b5 = b.(|5|) in let b6 = b.(|6|) in let b7 = b.(|7|) in let ws0 = SpecVec.load_elementi b0 0 in let ws1 = SpecVec.load_elementi b1 0 in let ws2 = SpecVec.load_elementi b2 0 in let ws3 = SpecVec.load_elementi b3 0 in let ws4 = SpecVec.load_elementi b4 0 in let ws5 = SpecVec.load_elementi b5 0 in let ws6 = SpecVec.load_elementi b6 0 in let ws7 = SpecVec.load_elementi b7 0 in let ws8 = SpecVec.load_elementi b0 1 in let ws9 = SpecVec.load_elementi b1 1 in let ws10 = SpecVec.load_elementi b2 1 in let ws11 = SpecVec.load_elementi b3 1 in let ws12 = SpecVec.load_elementi b4 1 in let ws13 = SpecVec.load_elementi b5 1 in let ws14 = SpecVec.load_elementi b6 1 in let ws15 = SpecVec.load_elementi b7 1 in LSeq.create16 ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 noextract let load_blocks_spec8_lemma (#a:sha2_alg) (#m:m_spec{lanes a m == 8}) (b:multiblock_spec a m) : Lemma (SpecVec.load_blocks b == load_blocks_spec8 b) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec8 b) inline_for_extraction noextract val load_blocks8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) #push-options "--z3rlimit 150" let load_blocks8 #a #m ib ws = let h0 = ST.get() in let (b0,(b1,(b2,(b3,(b4,(b5,(b6,b7))))))) = NTup.tup8 ib in set_wsi ws 0ul b0 0ul; set_wsi ws 1ul b1 0ul; set_wsi ws 2ul b2 0ul; set_wsi ws 3ul b3 0ul; set_wsi ws 4ul b4 0ul; set_wsi ws 5ul b5 0ul; set_wsi ws 6ul b6 0ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); set_wsi ws 7ul b7 0ul; set_wsi ws 8ul b0 1ul; set_wsi ws 9ul b1 1ul; set_wsi ws 10ul b2 1ul; set_wsi ws 11ul b3 1ul; set_wsi ws 12ul b4 1ul; set_wsi ws 13ul b5 1ul; set_wsi ws 14ul b6 1ul; set_wsi ws 15ul b7 1ul; let h1 = ST.get() in assert (modifies (loc ws) h0 h1); LSeq.eq_intro (as_seq h1 ws) (load_blocks_spec8 (as_seq_multi h0 ib)); load_blocks_spec8_lemma #a #m (as_seq_multi h0 ib); assert (as_seq h1 ws == load_blocks_spec8 (as_seq_multi h0 ib)); assert (as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 ib)); () #pop-options inline_for_extraction noextract val load_blocks: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_blocks (as_seq_multi h0 b)) let load_blocks #a #m b ws = match lanes a m with | 1 -> load_blocks1 b ws | 4 -> load_blocks4 b ws | 8 -> load_blocks8 b ws inline_for_extraction noextract val transpose_ws4: #a:sha2_alg -> #m:m_spec{lanes a m == 4} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws4 #a #m ws = let (ws0,ws1,ws2,ws3) = VecTranspose.transpose4x4 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul)) in let (ws4,ws5,ws6,ws7) = VecTranspose.transpose4x4 (ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11) = VecTranspose.transpose4x4 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul)) in let (ws12,ws13,ws14,ws15) = VecTranspose.transpose4x4 (ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws8: #a:sha2_alg -> #m:m_spec{lanes a m == 8} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws8 #a #m ws = let (ws0,ws1,ws2,ws3,ws4,ws5,ws6,ws7) = VecTranspose.transpose8x8 (ws.(0ul),ws.(1ul),ws.(2ul),ws.(3ul),ws.(4ul),ws.(5ul),ws.(6ul),ws.(7ul)) in let (ws8,ws9,ws10,ws11,ws12,ws13,ws14,ws15) = VecTranspose.transpose8x8 (ws.(8ul),ws.(9ul),ws.(10ul),ws.(11ul),ws.(12ul),ws.(13ul),ws.(14ul),ws.(15ul)) in create16 ws ws0 ws1 ws2 ws3 ws4 ws5 ws6 ws7 ws8 ws9 ws10 ws11 ws12 ws13 ws14 ws15 inline_for_extraction noextract val transpose_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> ws:ws_t a m -> Stack unit (requires fun h -> live h ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.transpose_ws (as_seq h0 ws)) let transpose_ws #a #m ws = match lanes a m with | 1 -> () | 4 -> transpose_ws4 ws | 8 -> transpose_ws8 ws inline_for_extraction noextract val load_ws: #a:sha2_alg -> #m:m_spec{is_supported a m} -> b:multibuf (lanes a m) (HD.block_len a) -> ws:ws_t a m -> Stack unit (requires fun h -> live_multi h b /\ live h ws /\ disjoint_multi b ws) (ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\ as_seq h1 ws == SpecVec.load_ws #a #m (as_seq_multi h0 b)) let load_ws #a #m b ws = load_blocks b ws; transpose_ws ws inline_for_extraction noextract let padded_blocks (a:sha2_alg) (len:size_t{v len <= block_length a}) : n:size_t{v n == SpecVec.padded_blocks a (v len)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul inline_for_extraction noextract val load_last_blocks: #a:sha2_alg -> totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:lbuffer uint8 len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (2ul *! HD.block_len a) -> Stack (lbuffer uint8 (HD.block_len a) & lbuffer uint8 (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live h b /\ live h last /\ disjoint b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (2 * block_length a) (u8 0)) (ensures (fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live h1 l0 /\ live h1 l1 /\ (forall a l (r:lbuffer a l). disjoint last r ==> (disjoint l0 r /\ disjoint l1 r)) /\ (as_seq h1 l0, as_seq h1 l1) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b))) #push-options "--z3rlimit 200" let load_last_blocks #a totlen_buf len b fin last = let h0 = ST.get() in update_sub last 0ul len b; last.(len) <- u8 0x80; update_sub last (fin -. len_len a) (len_len a) totlen_buf; let last0 : lbuffer uint8 (HD.block_len a) = sub last 0ul (HD.block_len a) in let last1 : lbuffer uint8 (HD.block_len a) = sub last (HD.block_len a) (HD.block_len a) in let h1 = ST.get() in assert (modifies (loc last) h0 h1); (last0,last1) #pop-options noextract let preserves_sub_disjoint_multi #lanes #len #len' (b:lbuffer uint8 len) (r:multibuf lanes len') = (forall a l (x:lbuffer a l). disjoint b x ==> disjoint_multi r x) inline_for_extraction noextract let load_last_t (a:sha2_alg) (m:m_spec{is_supported a m}) = totlen_buf:lbuffer uint8 (len_len a) -> len:size_t{v len <= block_length a} -> b:multibuf (lanes a m) len -> fin:size_t{v fin == block_length a \/ v fin == 2 * block_length a} -> last:lbuffer uint8 (size (lanes a m) *! 2ul *! HD.block_len a) -> Stack (multibuf (lanes a m) (HD.block_len a) & multibuf (lanes a m) (HD.block_len a)) (requires fun h -> live h totlen_buf /\ live_multi h b /\ live h last /\ disjoint_multi b last /\ disjoint last totlen_buf /\ as_seq h last == LSeq.create (lanes a m * 2 * block_length a) (u8 0)) (ensures fun h0 (l0,l1) h1 -> modifies (loc last) h0 h1 /\ live_multi h1 l0 /\ live_multi h1 l1 /\ preserves_sub_disjoint_multi last l0 /\ preserves_sub_disjoint_multi last l1 /\ (as_seq_multi h1 l0, as_seq_multi h1 l1) == SpecVec.load_last #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)) inline_for_extraction noextract val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m #push-options "--z3rlimit 250" let load_last1 #a #m totlen_buf len b fin last = let h0 = ST.get() in let b0 = b.(|0|) in let (l0,l1) = load_last_blocks #a totlen_buf len b0 fin last in let lb0 : multibuf (lanes a m) (HD.block_len a) = ntup1 l0 in let lb1 : multibuf (lanes a m) (HD.block_len a) = ntup1 l1 in let h1 = ST.get() in assert (modifies (loc last) h0 h1); NTup.eq_intro (as_seq_multi h0 b) (ntup1 (as_seq h0 b0)); NTup.eq_intro (as_seq_multi h1 lb0) (ntup1 (as_seq h1 l0)); NTup.eq_intro (as_seq_multi h1 lb1) (ntup1 (as_seq h1 l1)); assert ((as_seq_multi h1 lb0, as_seq_multi h1 lb1) == SpecVec.load_last1 #a #m (as_seq h0 totlen_buf) (v fin) (v len) (as_seq_multi h0 b)); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (lb0,lb1) #pop-options inline_for_extraction noextract val load_last4: #a:sha2_alg -> #m:m_spec{lanes a m = 4} -> load_last_t a m #push-options "--z3rlimit 350" let load_last4 #a #m totlen_buf len b fin last = let h0 = ST.get() in let (b0,(b1,(b2,b3))) = NTup.tup4 b in let last0 = sub last 0ul (2ul *! HD.block_len a) in let last1 = sub last (2ul *! HD.block_len a) (2ul *! HD.block_len a) in let last2 = sub last (4ul *! HD.block_len a) (2ul *! HD.block_len a) in let last3 = sub last (6ul *! HD.block_len a) (2ul *! HD.block_len a) in let h1 = ST.get() in assert (disjoint last0 last1); LSeq.eq_intro (as_seq h1 last0) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last1) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last2) (LSeq.create (2 * block_length a) (u8 0)); LSeq.eq_intro (as_seq h1 last3) (LSeq.create (2 * block_length a) (u8 0)); let (l00,l01) = load_last_blocks #a totlen_buf len b0 fin last0 in let (l10,l11) = load_last_blocks #a totlen_buf len b1 fin last1 in let (l20,l21) = load_last_blocks #a totlen_buf len b2 fin last2 in let (l30,l31) = load_last_blocks #a totlen_buf len b3 fin last3 in let mb0:multibuf (lanes a m) (HD.block_len a) = ntup4 (l00, (l10, (l20, l30))) in let mb1:multibuf (lanes a m) (HD.block_len a) = ntup4 (l01, (l11, (l21, l31))) in let h1 = ST.get() in assert ((as_seq h1 l00, as_seq h1 l01) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b0)); assert ((as_seq h1 l10, as_seq h1 l11) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b1)); assert ((as_seq h1 l20, as_seq h1 l21) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b2)); assert ((as_seq h1 l30, as_seq h1 l31) == SpecVec.load_last_blocks #a (as_seq h0 totlen_buf) (v fin) (v len) (as_seq h0 b3)); NTup.eq_intro (as_seq_multi h1 mb0) (ntup4 (as_seq h1 l00, (as_seq h1 l10, (as_seq h1 l20, (as_seq h1 l30))))); NTup.eq_intro (as_seq_multi h1 mb1) (ntup4 (as_seq h1 l01, (as_seq h1 l11, (as_seq h1 l21, (as_seq h1 l31))))); assert (modifies (loc last0 |+| loc last1 |+| loc last2 |+| loc last3) h0 h1); assert (modifies (loc last) h0 h1); assert (live_multi h1 mb0); assert (live_multi h1 mb1); reveal_opaque (`%SpecVec.load_last) (SpecVec.load_last #a #m); (mb0, mb1) #pop-options inline_for_extraction noextract val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m
false
false
Hacl.Impl.SHA2.Core.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 600, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val load_last8: #a:sha2_alg -> #m:m_spec{lanes a m = 8} -> load_last_t a m
[]
Hacl.Impl.SHA2.Core.load_last8
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.SHA2.Core.load_last_t a m
{ "end_col": 12, "end_line": 533, "start_col": 48, "start_line": 481 }
FStar.Tactics.Effect.Tac
val on_sort_binder (f: (term -> Tac term)) (b: binder) : Tac binder
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": 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 on_sort_binder (f : term -> Tac term) (b:binder) : Tac binder = let bview = inspect_binder b in let bview = { bview with sort = f bview.sort } in pack_binder bview
val on_sort_binder (f: (term -> Tac term)) (b: binder) : Tac binder let on_sort_binder (f: (term -> Tac term)) (b: binder) : Tac binder =
true
null
false
let bview = inspect_binder b in let bview = { bview with sort = f bview.sort } in pack_binder bview
{ "checked_file": "FStar.Tactics.Visit.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Visit.fst" }
[]
[ "FStar.Reflection.Types.term", "FStar.Reflection.Types.binder", "FStar.Reflection.V2.Builtins.pack_binder", "FStar.Reflection.V2.Data.binder_view", "FStar.Reflection.V2.Data.Mkbinder_view", "FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__qual", "FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__attrs", "FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__ppname", "FStar.Reflection.Types.typ", "FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__sort", "Prims.precedes", "FStar.Reflection.V2.Builtins.inspect_binder" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Visit (* Visit a term and transform it step by step. *) open FStar.Reflection.V2 open FStar.Tactics.Effect open FStar.Tactics.Types open FStar.Tactics.Util
false
false
FStar.Tactics.Visit.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 on_sort_binder (f: (term -> Tac term)) (b: binder) : Tac binder
[]
FStar.Tactics.Visit.on_sort_binder
{ "file_name": "ulib/FStar.Tactics.Visit.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term) -> b: FStar.Reflection.Types.binder -> FStar.Tactics.Effect.Tac FStar.Reflection.Types.binder
{ "end_col": 19, "end_line": 28, "start_col": 67, "start_line": 25 }
FStar.Tactics.Effect.Tac
val on_sort_simple_binder (f: (term -> Tac term)) (b: simple_binder) : Tac simple_binder
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": 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 on_sort_simple_binder (f : term -> Tac term) (b:simple_binder) : Tac simple_binder = let bview = inspect_binder b in let bview = { bview with sort = f bview.sort } in inspect_pack_binder bview; pack_binder bview
val on_sort_simple_binder (f: (term -> Tac term)) (b: simple_binder) : Tac simple_binder let on_sort_simple_binder (f: (term -> Tac term)) (b: simple_binder) : Tac simple_binder =
true
null
false
let bview = inspect_binder b in let bview = { bview with sort = f bview.sort } in inspect_pack_binder bview; pack_binder bview
{ "checked_file": "FStar.Tactics.Visit.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Visit.fst" }
[]
[ "FStar.Reflection.Types.term", "FStar.Reflection.V2.Data.simple_binder", "FStar.Reflection.V2.Builtins.pack_binder", "Prims.unit", "FStar.Reflection.V2.Builtins.inspect_pack_binder", "FStar.Reflection.V2.Data.binder_view", "FStar.Reflection.V2.Data.Mkbinder_view", "FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__qual", "FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__attrs", "FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__ppname", "FStar.Reflection.Types.typ", "FStar.Reflection.V2.Data.__proj__Mkbinder_view__item__sort", "Prims.precedes", "FStar.Reflection.Types.binder", "FStar.Reflection.V2.Builtins.inspect_binder" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Visit (* Visit a term and transform it step by step. *) open FStar.Reflection.V2 open FStar.Tactics.Effect open FStar.Tactics.Types open FStar.Tactics.Util let on_sort_binder (f : term -> Tac term) (b:binder) : Tac binder = let bview = inspect_binder b in let bview = { bview with sort = f bview.sort } in pack_binder bview
false
false
FStar.Tactics.Visit.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 on_sort_simple_binder (f: (term -> Tac term)) (b: simple_binder) : Tac simple_binder
[]
FStar.Tactics.Visit.on_sort_simple_binder
{ "file_name": "ulib/FStar.Tactics.Visit.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term) -> b: FStar.Reflection.V2.Data.simple_binder -> FStar.Tactics.Effect.Tac FStar.Reflection.V2.Data.simple_binder
{ "end_col": 19, "end_line": 35, "start_col": 88, "start_line": 31 }
Prims.Tot
val on_domain (a: Type) (#b: (a -> Type)) ([@@@strictly_positive] f: arrow a b) : Tot (arrow a b)
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 on_domain (a:Type) (#b:a -> Type) ([@@@strictly_positive] f:arrow a b) = fun (x:a) -> f x
val on_domain (a: Type) (#b: (a -> Type)) ([@@@strictly_positive] f: arrow a b) : Tot (arrow a b) let on_domain (a: Type) (#b: (a -> Type)) ([@@@ strictly_positive]f: arrow a b) =
false
null
false
fun (x: a) -> f x
{ "checked_file": "FStar.FunctionalExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ "total" ]
[ "FStar.FunctionalExtensionality.arrow" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.FunctionalExtensionality inline_for_extraction
false
false
FStar.FunctionalExtensionality.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 on_domain (a: Type) (#b: (a -> Type)) ([@@@strictly_positive] f: arrow a b) : Tot (arrow a b)
[]
FStar.FunctionalExtensionality.on_domain
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> f: FStar.FunctionalExtensionality.arrow a b -> FStar.FunctionalExtensionality.arrow a b
{ "end_col": 20, "end_line": 21, "start_col": 4, "start_line": 21 }
FStar.Tactics.Effect.Tac
val l_to_r (t: term) : Tac unit
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 l_to_r (t:term) : Tac unit = ctrl_rewrite BottomUp (fun _ -> true, Continue) (fun _ -> try t_apply_lemma false true t with _ -> t_trefl false)
val l_to_r (t: term) : Tac unit let l_to_r (t: term) : Tac unit =
true
null
false
ctrl_rewrite BottomUp (fun _ -> true, Continue) (fun _ -> try t_apply_lemma false true t with | _ -> t_trefl false)
{ "checked_file": "FStar.FunctionalExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[]
[ "FStar.Reflection.Types.term", "FStar.Tactics.V2.Builtins.ctrl_rewrite", "FStar.Tactics.Types.BottomUp", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "FStar.Tactics.Types.ctrl_flag", "FStar.Tactics.Types.Continue", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.FunctionalExtensionality.try_with", "FStar.Tactics.V2.Builtins.t_apply_lemma", "Prims.exn", "FStar.Tactics.V2.Builtins.t_trefl" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.FunctionalExtensionality inline_for_extraction let on_domain (a:Type) (#b:a -> Type) ([@@@strictly_positive] f:arrow a b) = fun (x:a) -> f x let feq_on_domain (#a:Type) (#b:a -> Type) (f:arrow a b) = () let idempotence_on_domain #a #b f = assert_norm (on_domain a f == (on_domain a (on_domain a f))) let quantifier_as_lemma (#a:Type) (#b: a -> Type) (f:squash (forall (x:a). b x)) (x:a) : Lemma (b x) = () open FStar.Tactics.V2.Builtins open FStar.Reflection.Types open FStar.Tactics.Types open FStar.Tactics.Effect (* we're early enough in the module stack that we need to reimplement a few of the tactic helpers *) noextract let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x noextract
false
false
FStar.FunctionalExtensionality.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 l_to_r (t: term) : Tac unit
[]
FStar.FunctionalExtensionality.l_to_r
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 30, "end_line": 53, "start_col": 2, "start_line": 49 }
Prims.Tot
val on_domain_g (a: Type) (#b: (a -> Type)) (f: arrow_g a b) : Tot (arrow_g a b)
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 on_domain_g (a:Type) (#b:a -> Type) (f:arrow_g a b) = fun (x:a) -> f x
val on_domain_g (a: Type) (#b: (a -> Type)) (f: arrow_g a b) : Tot (arrow_g a b) let on_domain_g (a: Type) (#b: (a -> Type)) (f: arrow_g a b) =
false
null
false
fun (x: a) -> f x
{ "checked_file": "FStar.FunctionalExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ "total" ]
[ "FStar.FunctionalExtensionality.arrow_g" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.FunctionalExtensionality inline_for_extraction let on_domain (a:Type) (#b:a -> Type) ([@@@strictly_positive] f:arrow a b) = fun (x:a) -> f x let feq_on_domain (#a:Type) (#b:a -> Type) (f:arrow a b) = () let idempotence_on_domain #a #b f = assert_norm (on_domain a f == (on_domain a (on_domain a f))) let quantifier_as_lemma (#a:Type) (#b: a -> Type) (f:squash (forall (x:a). b x)) (x:a) : Lemma (b x) = () open FStar.Tactics.V2.Builtins open FStar.Reflection.Types open FStar.Tactics.Types open FStar.Tactics.Effect (* we're early enough in the module stack that we need to reimplement a few of the tactic helpers *) noextract let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x noextract let l_to_r (t:term) : Tac unit = ctrl_rewrite BottomUp (fun _ -> true, Continue) (fun _ -> try t_apply_lemma false true t with _ -> t_trefl false) let extensionality_1 (a:Type) (b: a -> Type) (f g: arrow a b) (sq_feq : squash (feq f g)) : Lemma (ensures on_domain a f == on_domain a g) = assert (on_domain a f == on_domain a g) by (norm [delta_only [`%on_domain]]; l_to_r (quote (quantifier_as_lemma sq_feq)); t_trefl false) let extensionality a b f g = let fwd a b (f g:arrow a b) : Lemma (requires feq #a #b f g) (ensures on_domain a f == on_domain a g) [SMTPat (feq #a #b f g)] = extensionality_1 a b f g () in () (****** GTot version ******)
false
false
FStar.FunctionalExtensionality.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 on_domain_g (a: Type) (#b: (a -> Type)) (f: arrow_g a b) : Tot (arrow_g a b)
[]
FStar.FunctionalExtensionality.on_domain_g
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> f: FStar.FunctionalExtensionality.arrow_g a b -> FStar.FunctionalExtensionality.arrow_g a b
{ "end_col": 20, "end_line": 78, "start_col": 4, "start_line": 78 }
FStar.Pervasives.Lemma
val idempotence_on_domain (#a: Type) (#b: (a -> Type)) (f: arrow a b) : Lemma (on_domain a (on_domain a f) == on_domain a f) [SMTPat (on_domain a (on_domain a f))]
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 idempotence_on_domain #a #b f = assert_norm (on_domain a f == (on_domain a (on_domain a f)))
val idempotence_on_domain (#a: Type) (#b: (a -> Type)) (f: arrow a b) : Lemma (on_domain a (on_domain a f) == on_domain a f) [SMTPat (on_domain a (on_domain a f))] let idempotence_on_domain #a #b f =
false
null
true
assert_norm (on_domain a f == (on_domain a (on_domain a f)))
{ "checked_file": "FStar.FunctionalExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ "lemma" ]
[ "FStar.FunctionalExtensionality.arrow", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.FunctionalExtensionality.on_domain", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.FunctionalExtensionality inline_for_extraction let on_domain (a:Type) (#b:a -> Type) ([@@@strictly_positive] f:arrow a b) = fun (x:a) -> f x let feq_on_domain (#a:Type) (#b:a -> Type) (f:arrow a b) = ()
false
false
FStar.FunctionalExtensionality.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 idempotence_on_domain (#a: Type) (#b: (a -> Type)) (f: arrow a b) : Lemma (on_domain a (on_domain a f) == on_domain a f) [SMTPat (on_domain a (on_domain a f))]
[]
FStar.FunctionalExtensionality.idempotence_on_domain
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: FStar.FunctionalExtensionality.arrow a b -> FStar.Pervasives.Lemma (ensures FStar.FunctionalExtensionality.on_domain a (FStar.FunctionalExtensionality.on_domain a f) == FStar.FunctionalExtensionality.on_domain a f) [ SMTPat (FStar.FunctionalExtensionality.on_domain a (FStar.FunctionalExtensionality.on_domain a f)) ]
{ "end_col": 64, "end_line": 27, "start_col": 4, "start_line": 27 }
FStar.Pervasives.Lemma
val idempotence_on_domain_g (#a: Type) (#b: (a -> Type)) (f: arrow_g a b) : Lemma (on_domain_g a (on_domain_g a f) == on_domain_g a f) [SMTPat (on_domain_g a (on_domain_g a f))]
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 idempotence_on_domain_g #a #b f = assert_norm (on_domain_g a f == (on_domain_g a (on_domain_g a f)))
val idempotence_on_domain_g (#a: Type) (#b: (a -> Type)) (f: arrow_g a b) : Lemma (on_domain_g a (on_domain_g a f) == on_domain_g a f) [SMTPat (on_domain_g a (on_domain_g a f))] let idempotence_on_domain_g #a #b f =
false
null
true
assert_norm (on_domain_g a f == (on_domain_g a (on_domain_g a f)))
{ "checked_file": "FStar.FunctionalExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ "lemma" ]
[ "FStar.FunctionalExtensionality.arrow_g", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.FunctionalExtensionality.on_domain_g", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.FunctionalExtensionality inline_for_extraction let on_domain (a:Type) (#b:a -> Type) ([@@@strictly_positive] f:arrow a b) = fun (x:a) -> f x let feq_on_domain (#a:Type) (#b:a -> Type) (f:arrow a b) = () let idempotence_on_domain #a #b f = assert_norm (on_domain a f == (on_domain a (on_domain a f))) let quantifier_as_lemma (#a:Type) (#b: a -> Type) (f:squash (forall (x:a). b x)) (x:a) : Lemma (b x) = () open FStar.Tactics.V2.Builtins open FStar.Reflection.Types open FStar.Tactics.Types open FStar.Tactics.Effect (* we're early enough in the module stack that we need to reimplement a few of the tactic helpers *) noextract let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x noextract let l_to_r (t:term) : Tac unit = ctrl_rewrite BottomUp (fun _ -> true, Continue) (fun _ -> try t_apply_lemma false true t with _ -> t_trefl false) let extensionality_1 (a:Type) (b: a -> Type) (f g: arrow a b) (sq_feq : squash (feq f g)) : Lemma (ensures on_domain a f == on_domain a g) = assert (on_domain a f == on_domain a g) by (norm [delta_only [`%on_domain]]; l_to_r (quote (quantifier_as_lemma sq_feq)); t_trefl false) let extensionality a b f g = let fwd a b (f g:arrow a b) : Lemma (requires feq #a #b f g) (ensures on_domain a f == on_domain a g) [SMTPat (feq #a #b f g)] = extensionality_1 a b f g () in () (****** GTot version ******) let on_domain_g (a:Type) (#b:a -> Type) (f:arrow_g a b) = fun (x:a) -> f x let feq_on_domain_g (#a:Type) (#b:a -> Type) (f:arrow_g a b) = ()
false
false
FStar.FunctionalExtensionality.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 idempotence_on_domain_g (#a: Type) (#b: (a -> Type)) (f: arrow_g a b) : Lemma (on_domain_g a (on_domain_g a f) == on_domain_g a f) [SMTPat (on_domain_g a (on_domain_g a f))]
[]
FStar.FunctionalExtensionality.idempotence_on_domain_g
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: FStar.FunctionalExtensionality.arrow_g a b -> FStar.Pervasives.Lemma (ensures FStar.FunctionalExtensionality.on_domain_g a (FStar.FunctionalExtensionality.on_domain_g a f) == FStar.FunctionalExtensionality.on_domain_g a f) [ SMTPat (FStar.FunctionalExtensionality.on_domain_g a (FStar.FunctionalExtensionality.on_domain_g a f)) ]
{ "end_col": 70, "end_line": 84, "start_col": 4, "start_line": 84 }
FStar.Pervasives.Lemma
val extensionality (a: Type) (b: (a -> Type)) (f g: arrow a b) : Lemma (ensures (feq #a #b f g <==> on_domain a f == on_domain a g)) [SMTPat (feq #a #b f g)]
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 extensionality a b f g = let fwd a b (f g:arrow a b) : Lemma (requires feq #a #b f g) (ensures on_domain a f == on_domain a g) [SMTPat (feq #a #b f g)] = extensionality_1 a b f g () in ()
val extensionality (a: Type) (b: (a -> Type)) (f g: arrow a b) : Lemma (ensures (feq #a #b f g <==> on_domain a f == on_domain a g)) [SMTPat (feq #a #b f g)] let extensionality a b f g =
false
null
true
let fwd a b (f: arrow a b) (g: arrow a b) : Lemma (requires feq #a #b f g) (ensures on_domain a f == on_domain a g) [SMTPat (feq #a #b f g)] = extensionality_1 a b f g () in ()
{ "checked_file": "FStar.FunctionalExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ "lemma" ]
[ "FStar.FunctionalExtensionality.arrow", "Prims.unit", "FStar.FunctionalExtensionality.feq", "Prims.squash", "Prims.eq2", "FStar.FunctionalExtensionality.on_domain", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.logical", "Prims.Nil", "FStar.FunctionalExtensionality.extensionality_1" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.FunctionalExtensionality inline_for_extraction let on_domain (a:Type) (#b:a -> Type) ([@@@strictly_positive] f:arrow a b) = fun (x:a) -> f x let feq_on_domain (#a:Type) (#b:a -> Type) (f:arrow a b) = () let idempotence_on_domain #a #b f = assert_norm (on_domain a f == (on_domain a (on_domain a f))) let quantifier_as_lemma (#a:Type) (#b: a -> Type) (f:squash (forall (x:a). b x)) (x:a) : Lemma (b x) = () open FStar.Tactics.V2.Builtins open FStar.Reflection.Types open FStar.Tactics.Types open FStar.Tactics.Effect (* we're early enough in the module stack that we need to reimplement a few of the tactic helpers *) noextract let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x noextract let l_to_r (t:term) : Tac unit = ctrl_rewrite BottomUp (fun _ -> true, Continue) (fun _ -> try t_apply_lemma false true t with _ -> t_trefl false) let extensionality_1 (a:Type) (b: a -> Type) (f g: arrow a b) (sq_feq : squash (feq f g)) : Lemma (ensures on_domain a f == on_domain a g) = assert (on_domain a f == on_domain a g) by (norm [delta_only [`%on_domain]]; l_to_r (quote (quantifier_as_lemma sq_feq)); t_trefl false)
false
false
FStar.FunctionalExtensionality.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 extensionality (a: Type) (b: (a -> Type)) (f g: arrow a b) : Lemma (ensures (feq #a #b f g <==> on_domain a f == on_domain a g)) [SMTPat (feq #a #b f g)]
[]
FStar.FunctionalExtensionality.extensionality
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> b: (_: a -> Type) -> f: FStar.FunctionalExtensionality.arrow a b -> g: FStar.FunctionalExtensionality.arrow a b -> FStar.Pervasives.Lemma (ensures FStar.FunctionalExtensionality.feq f g <==> FStar.FunctionalExtensionality.on_domain a f == FStar.FunctionalExtensionality.on_domain a g ) [SMTPat (FStar.FunctionalExtensionality.feq f g)]
{ "end_col": 6, "end_line": 72, "start_col": 3, "start_line": 66 }
FStar.Pervasives.Lemma
val extensionality_g (a: Type) (b: (a -> Type)) (f g: arrow_g a b) : Lemma (ensures (feq_g #a #b f g <==> on_domain_g a f == on_domain_g a g)) [SMTPat (feq_g #a #b f g)]
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 extensionality_g a b f g = let fwd a b (f g:arrow_g a b) : Lemma (requires feq_g #a #b f g) (ensures on_domain_g a f == on_domain_g a g) [SMTPat (feq_g #a #b f g)] = extensionality_1_g a b f g () in ()
val extensionality_g (a: Type) (b: (a -> Type)) (f g: arrow_g a b) : Lemma (ensures (feq_g #a #b f g <==> on_domain_g a f == on_domain_g a g)) [SMTPat (feq_g #a #b f g)] let extensionality_g a b f g =
false
null
true
let fwd a b (f: arrow_g a b) (g: arrow_g a b) : Lemma (requires feq_g #a #b f g) (ensures on_domain_g a f == on_domain_g a g) [SMTPat (feq_g #a #b f g)] = extensionality_1_g a b f g () in ()
{ "checked_file": "FStar.FunctionalExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ "lemma" ]
[ "FStar.FunctionalExtensionality.arrow_g", "Prims.unit", "FStar.FunctionalExtensionality.feq_g", "Prims.squash", "Prims.eq2", "FStar.FunctionalExtensionality.on_domain_g", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.logical", "Prims.Nil", "FStar.FunctionalExtensionality.extensionality_1_g" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.FunctionalExtensionality inline_for_extraction let on_domain (a:Type) (#b:a -> Type) ([@@@strictly_positive] f:arrow a b) = fun (x:a) -> f x let feq_on_domain (#a:Type) (#b:a -> Type) (f:arrow a b) = () let idempotence_on_domain #a #b f = assert_norm (on_domain a f == (on_domain a (on_domain a f))) let quantifier_as_lemma (#a:Type) (#b: a -> Type) (f:squash (forall (x:a). b x)) (x:a) : Lemma (b x) = () open FStar.Tactics.V2.Builtins open FStar.Reflection.Types open FStar.Tactics.Types open FStar.Tactics.Effect (* we're early enough in the module stack that we need to reimplement a few of the tactic helpers *) noextract let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x noextract let l_to_r (t:term) : Tac unit = ctrl_rewrite BottomUp (fun _ -> true, Continue) (fun _ -> try t_apply_lemma false true t with _ -> t_trefl false) let extensionality_1 (a:Type) (b: a -> Type) (f g: arrow a b) (sq_feq : squash (feq f g)) : Lemma (ensures on_domain a f == on_domain a g) = assert (on_domain a f == on_domain a g) by (norm [delta_only [`%on_domain]]; l_to_r (quote (quantifier_as_lemma sq_feq)); t_trefl false) let extensionality a b f g = let fwd a b (f g:arrow a b) : Lemma (requires feq #a #b f g) (ensures on_domain a f == on_domain a g) [SMTPat (feq #a #b f g)] = extensionality_1 a b f g () in () (****** GTot version ******) let on_domain_g (a:Type) (#b:a -> Type) (f:arrow_g a b) = fun (x:a) -> f x let feq_on_domain_g (#a:Type) (#b:a -> Type) (f:arrow_g a b) = () let idempotence_on_domain_g #a #b f = assert_norm (on_domain_g a f == (on_domain_g a (on_domain_g a f))) let extensionality_1_g (a:Type) (b: a -> Type) (f g: arrow_g a b) (sq_feq : squash (feq_g f g)) : Lemma (ensures on_domain_g a f == on_domain_g a g) = assert (on_domain_g a f == on_domain_g a g) by (norm [delta_only [`%on_domain_g]]; l_to_r (quote (quantifier_as_lemma sq_feq)); t_trefl false)
false
false
FStar.FunctionalExtensionality.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 extensionality_g (a: Type) (b: (a -> Type)) (f g: arrow_g a b) : Lemma (ensures (feq_g #a #b f g <==> on_domain_g a f == on_domain_g a g)) [SMTPat (feq_g #a #b f g)]
[]
FStar.FunctionalExtensionality.extensionality_g
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> b: (_: a -> Type) -> f: FStar.FunctionalExtensionality.arrow_g a b -> g: FStar.FunctionalExtensionality.arrow_g a b -> FStar.Pervasives.Lemma (ensures FStar.FunctionalExtensionality.feq_g f g <==> FStar.FunctionalExtensionality.on_domain_g a f == FStar.FunctionalExtensionality.on_domain_g a g) [SMTPat (FStar.FunctionalExtensionality.feq_g f g)]
{ "end_col": 6, "end_line": 103, "start_col": 3, "start_line": 97 }
FStar.Pervasives.Lemma
val extensionality_1 (a: Type) (b: (a -> Type)) (f g: arrow a b) (sq_feq: squash (feq f g)) : Lemma (ensures on_domain a f == on_domain a g)
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 extensionality_1 (a:Type) (b: a -> Type) (f g: arrow a b) (sq_feq : squash (feq f g)) : Lemma (ensures on_domain a f == on_domain a g) = assert (on_domain a f == on_domain a g) by (norm [delta_only [`%on_domain]]; l_to_r (quote (quantifier_as_lemma sq_feq)); t_trefl false)
val extensionality_1 (a: Type) (b: (a -> Type)) (f g: arrow a b) (sq_feq: squash (feq f g)) : Lemma (ensures on_domain a f == on_domain a g) let extensionality_1 (a: Type) (b: (a -> Type)) (f g: arrow a b) (sq_feq: squash (feq f g)) : Lemma (ensures on_domain a f == on_domain a g) =
false
null
true
FStar.Tactics.Effect.assert_by_tactic (on_domain a f == on_domain a g) (fun _ -> (); (norm [delta_only [`%on_domain]]; l_to_r (quote (quantifier_as_lemma sq_feq)); t_trefl false))
{ "checked_file": "FStar.FunctionalExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ "lemma" ]
[ "FStar.FunctionalExtensionality.arrow", "Prims.squash", "FStar.FunctionalExtensionality.feq", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "FStar.FunctionalExtensionality.on_domain", "Prims.unit", "FStar.Tactics.V2.Builtins.t_trefl", "FStar.FunctionalExtensionality.l_to_r", "FStar.Reflection.Types.term", "FStar.FunctionalExtensionality.quantifier_as_lemma", "FStar.Tactics.V2.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "Prims.l_True", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.FunctionalExtensionality inline_for_extraction let on_domain (a:Type) (#b:a -> Type) ([@@@strictly_positive] f:arrow a b) = fun (x:a) -> f x let feq_on_domain (#a:Type) (#b:a -> Type) (f:arrow a b) = () let idempotence_on_domain #a #b f = assert_norm (on_domain a f == (on_domain a (on_domain a f))) let quantifier_as_lemma (#a:Type) (#b: a -> Type) (f:squash (forall (x:a). b x)) (x:a) : Lemma (b x) = () open FStar.Tactics.V2.Builtins open FStar.Reflection.Types open FStar.Tactics.Types open FStar.Tactics.Effect (* we're early enough in the module stack that we need to reimplement a few of the tactic helpers *) noextract let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x noextract let l_to_r (t:term) : Tac unit = ctrl_rewrite BottomUp (fun _ -> true, Continue) (fun _ -> try t_apply_lemma false true t with _ -> t_trefl false) let extensionality_1 (a:Type) (b: a -> Type) (f g: arrow a b) (sq_feq : squash (feq f g))
false
false
FStar.FunctionalExtensionality.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 extensionality_1 (a: Type) (b: (a -> Type)) (f g: arrow a b) (sq_feq: squash (feq f g)) : Lemma (ensures on_domain a f == on_domain a g)
[]
FStar.FunctionalExtensionality.extensionality_1
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> b: (_: a -> Type) -> f: FStar.FunctionalExtensionality.arrow a b -> g: FStar.FunctionalExtensionality.arrow a b -> sq_feq: Prims.squash (FStar.FunctionalExtensionality.feq f g) -> FStar.Pervasives.Lemma (ensures FStar.FunctionalExtensionality.on_domain a f == FStar.FunctionalExtensionality.on_domain a g)
{ "end_col": 26, "end_line": 63, "start_col": 4, "start_line": 60 }
FStar.Pervasives.Lemma
val extensionality_1_g (a: Type) (b: (a -> Type)) (f g: arrow_g a b) (sq_feq: squash (feq_g f g)) : Lemma (ensures on_domain_g a f == on_domain_g a g)
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 extensionality_1_g (a:Type) (b: a -> Type) (f g: arrow_g a b) (sq_feq : squash (feq_g f g)) : Lemma (ensures on_domain_g a f == on_domain_g a g) = assert (on_domain_g a f == on_domain_g a g) by (norm [delta_only [`%on_domain_g]]; l_to_r (quote (quantifier_as_lemma sq_feq)); t_trefl false)
val extensionality_1_g (a: Type) (b: (a -> Type)) (f g: arrow_g a b) (sq_feq: squash (feq_g f g)) : Lemma (ensures on_domain_g a f == on_domain_g a g) let extensionality_1_g (a: Type) (b: (a -> Type)) (f g: arrow_g a b) (sq_feq: squash (feq_g f g)) : Lemma (ensures on_domain_g a f == on_domain_g a g) =
false
null
true
FStar.Tactics.Effect.assert_by_tactic (on_domain_g a f == on_domain_g a g) (fun _ -> (); (norm [delta_only [`%on_domain_g]]; l_to_r (quote (quantifier_as_lemma sq_feq)); t_trefl false))
{ "checked_file": "FStar.FunctionalExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ "lemma" ]
[ "FStar.FunctionalExtensionality.arrow_g", "Prims.squash", "FStar.FunctionalExtensionality.feq_g", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "FStar.FunctionalExtensionality.on_domain_g", "Prims.unit", "FStar.Tactics.V2.Builtins.t_trefl", "FStar.FunctionalExtensionality.l_to_r", "FStar.Reflection.Types.term", "FStar.FunctionalExtensionality.quantifier_as_lemma", "FStar.Tactics.V2.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "Prims.l_True", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.FunctionalExtensionality inline_for_extraction let on_domain (a:Type) (#b:a -> Type) ([@@@strictly_positive] f:arrow a b) = fun (x:a) -> f x let feq_on_domain (#a:Type) (#b:a -> Type) (f:arrow a b) = () let idempotence_on_domain #a #b f = assert_norm (on_domain a f == (on_domain a (on_domain a f))) let quantifier_as_lemma (#a:Type) (#b: a -> Type) (f:squash (forall (x:a). b x)) (x:a) : Lemma (b x) = () open FStar.Tactics.V2.Builtins open FStar.Reflection.Types open FStar.Tactics.Types open FStar.Tactics.Effect (* we're early enough in the module stack that we need to reimplement a few of the tactic helpers *) noextract let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x noextract let l_to_r (t:term) : Tac unit = ctrl_rewrite BottomUp (fun _ -> true, Continue) (fun _ -> try t_apply_lemma false true t with _ -> t_trefl false) let extensionality_1 (a:Type) (b: a -> Type) (f g: arrow a b) (sq_feq : squash (feq f g)) : Lemma (ensures on_domain a f == on_domain a g) = assert (on_domain a f == on_domain a g) by (norm [delta_only [`%on_domain]]; l_to_r (quote (quantifier_as_lemma sq_feq)); t_trefl false) let extensionality a b f g = let fwd a b (f g:arrow a b) : Lemma (requires feq #a #b f g) (ensures on_domain a f == on_domain a g) [SMTPat (feq #a #b f g)] = extensionality_1 a b f g () in () (****** GTot version ******) let on_domain_g (a:Type) (#b:a -> Type) (f:arrow_g a b) = fun (x:a) -> f x let feq_on_domain_g (#a:Type) (#b:a -> Type) (f:arrow_g a b) = () let idempotence_on_domain_g #a #b f = assert_norm (on_domain_g a f == (on_domain_g a (on_domain_g a f))) let extensionality_1_g (a:Type) (b: a -> Type) (f g: arrow_g a b) (sq_feq : squash (feq_g f g))
false
false
FStar.FunctionalExtensionality.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 extensionality_1_g (a: Type) (b: (a -> Type)) (f g: arrow_g a b) (sq_feq: squash (feq_g f g)) : Lemma (ensures on_domain_g a f == on_domain_g a g)
[]
FStar.FunctionalExtensionality.extensionality_1_g
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> b: (_: a -> Type) -> f: FStar.FunctionalExtensionality.arrow_g a b -> g: FStar.FunctionalExtensionality.arrow_g a b -> sq_feq: Prims.squash (FStar.FunctionalExtensionality.feq_g f g) -> FStar.Pervasives.Lemma (ensures FStar.FunctionalExtensionality.on_domain_g a f == FStar.FunctionalExtensionality.on_domain_g a g)
{ "end_col": 26, "end_line": 94, "start_col": 4, "start_line": 91 }
FStar.Tactics.Effect.Tac
val try_with (f: (unit -> Tac 'a)) (h: (exn -> Tac 'a)) : Tac 'a
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": 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 try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x
val try_with (f: (unit -> Tac 'a)) (h: (exn -> Tac 'a)) : Tac 'a let try_with (f: (unit -> Tac 'a)) (h: (exn -> Tac 'a)) : Tac 'a =
true
null
false
match catch f with | Inl e -> h e | Inr x -> x
{ "checked_file": "FStar.FunctionalExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[]
[ "Prims.unit", "Prims.exn", "FStar.Pervasives.either", "FStar.Tactics.V2.Builtins.catch" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.FunctionalExtensionality inline_for_extraction let on_domain (a:Type) (#b:a -> Type) ([@@@strictly_positive] f:arrow a b) = fun (x:a) -> f x let feq_on_domain (#a:Type) (#b:a -> Type) (f:arrow a b) = () let idempotence_on_domain #a #b f = assert_norm (on_domain a f == (on_domain a (on_domain a f))) let quantifier_as_lemma (#a:Type) (#b: a -> Type) (f:squash (forall (x:a). b x)) (x:a) : Lemma (b x) = () open FStar.Tactics.V2.Builtins open FStar.Reflection.Types open FStar.Tactics.Types open FStar.Tactics.Effect (* we're early enough in the module stack that we need to reimplement a few of the tactic helpers *) noextract
false
false
FStar.FunctionalExtensionality.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 try_with (f: (unit -> Tac 'a)) (h: (exn -> Tac 'a)) : Tac 'a
[]
FStar.FunctionalExtensionality.try_with
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: Prims.unit -> FStar.Tactics.Effect.Tac 'a) -> h: (_: Prims.exn -> FStar.Tactics.Effect.Tac 'a) -> FStar.Tactics.Effect.Tac 'a
{ "end_col": 16, "end_line": 45, "start_col": 4, "start_line": 43 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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.Stdcalls.X64.GCMdecryptOpt.tuint64
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.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": 45, "start_col": 14, "start_line": 45 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public})
let t128_mod_pub =
false
null
false
TD_Buffer TUInt8 TUInt128 ({ modified = true; strict_disjointness = false; taint = MS.Public })
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.Interop.Base.TD_Buffer", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.Interop.Base.Mkbuffer_qualifiers", "Vale.Arch.HeapTypes_s.Public" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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 t128_mod_pub : Vale.Interop.Base.td
[]
Vale.Stdcalls.X64.GCMdecryptOpt.t128_mod_pub
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Interop.Base.td
{ "end_col": 106, "end_line": 41, "start_col": 19, "start_line": 41 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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_gcm256 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_256
let code_gcm256 =
false
null
false
GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_256
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall", "Vale.Interop.Assumptions.win", "Vale.AES.AES_common_s.AES_256" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm128 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm256_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm256_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm256_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm256_lemma' has the required type *) noextract let gcm256_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm256_pre s iv) (gcm256_post s iv)) (gcm256_lemma' s iv)
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val code_gcm256 : Vale.X64.Decls.va_code
[]
Vale.Stdcalls.X64.GCMdecryptOpt.code_gcm256
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.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": 70, "end_line": 375, "start_col": 18, "start_line": 375 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 b128 = buf_t TUInt8 TUInt128
let b128 =
false
null
false
buf_t TUInt8 TUInt128
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.Interop.Base.buf_t", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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 b128 : Type0
[]
Vale.Stdcalls.X64.GCMdecryptOpt.b128
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 32, "end_line": 37, "start_col": 11, "start_line": 37 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.UInt64.t" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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.Stdcalls.X64.GCMdecryptOpt.uint64
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.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": 28, "start_col": 13, "start_line": 28 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
let t128_mod =
false
null
false
TD_Buffer TUInt8 TUInt128 default_bq
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.Interop.Base.TD_Buffer", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.Interop.Base.default_bq" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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 t128_mod : Vale.Interop.Base.td
[]
Vale.Stdcalls.X64.GCMdecryptOpt.t128_mod
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Interop.Base.td
{ "end_col": 51, "end_line": 39, "start_col": 15, "start_line": 39 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
let t128_no_mod =
false
null
false
TD_Buffer TUInt8 TUInt128 ({ modified = false; strict_disjointness = false; taint = MS.Secret })
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.Interop.Base.TD_Buffer", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.Interop.Base.Mkbuffer_qualifiers", "Vale.Arch.HeapTypes_s.Secret" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public})
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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 t128_no_mod : Vale.Interop.Base.td
[]
Vale.Stdcalls.X64.GCMdecryptOpt.t128_no_mod
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Interop.Base.td
{ "end_col": 106, "end_line": 43, "start_col": 18, "start_line": 43 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128
let code_gcm128 =
false
null
false
GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall", "Vale.Interop.Assumptions.win", "Vale.AES.AES_common_s.AES_128" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv)
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val code_gcm128 : Vale.X64.Decls.va_code
[]
Vale.Stdcalls.X64.GCMdecryptOpt.code_gcm128
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.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": 70, "end_line": 203, "start_col": 18, "start_line": 203 }
Prims.Tot
val as_normal_t (#a: Type) (x: a) : normal a
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.Interop.Base.normal" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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.Stdcalls.X64.GCMdecryptOpt.as_normal_t
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.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": 34, "start_col": 45, "start_line": 34 }
Prims.Tot
val as_t (#a: Type) (x: normal a) : a
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.Interop.Base.normal" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *)
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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.Stdcalls.X64.GCMdecryptOpt.as_t
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.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": 32, "start_col": 38, "start_line": 32 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win))
let lowstar_gcm128_t (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) =
false
null
false
assert_norm (List.length dom + List.length ([] <: list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win))
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Interop.X64.as_lowstar_sig_t_weak_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.code_gcm128", "Vale.Stdcalls.X64.GCMdecryptOpt.dom", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Vale.Interop.X64.max_stdcall", "Vale.Interop.X64.arg_reg_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Interop.X64.regs_modified_stdcall", "Vale.Interop.X64.xmms_modified_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_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.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowstar_gcm128_t : s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Type0
[]
Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm128_t
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Type0
{ "end_col": 81, "end_line": 215, "start_col": 2, "start_line": 208 }
Prims.Tot
val dom:dom: list td {List.length dom <= 20}
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y
val dom:dom: list td {List.length dom <= 20} let dom:dom: list td {List.length dom <= 20} =
false
null
false
let y = [ t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod ] in assert_norm (List.length y = 17); y
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.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.Stdcalls.X64.GCMdecryptOpt.t128_no_mod", "Vale.Stdcalls.X64.GCMdecryptOpt.tuint64", "Vale.Stdcalls.X64.GCMdecryptOpt.t128_mod_pub", "Vale.Stdcalls.X64.GCMdecryptOpt.t128_mod", "Prims.Nil" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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 dom:dom: list td {List.length dom <= 20}
[]
Vale.Stdcalls.X64.GCMdecryptOpt.dom
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dom: Prims.list Vale.Interop.Base.td {FStar.List.Tot.Base.length dom <= 20}
{ "end_col": 3, "end_line": 52, "start_col": 43, "start_line": 48 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 gcm128_decrypt_opt //: normal ((s:Ghost.erased (Seq.seq nat32)) -> lowstar_gcm128_t s) = as_normal_t #((s:Ghost.erased (Seq.seq nat32)) -> (iv:Ghost.erased supported_iv_LE) -> lowstar_gcm128_t s iv) (fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) -> lowstar_gcm128 s iv)
let gcm128_decrypt_opt =
false
null
false
as_normal_t #(s: Ghost.erased (Seq.seq nat32) -> iv: Ghost.erased supported_iv_LE -> lowstar_gcm128_t s iv) (fun (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) -> lowstar_gcm128 s iv)
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.Stdcalls.X64.GCMdecryptOpt.as_normal_t", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm128_t", "Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm128" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm128 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm256_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm256_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm256_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm256_lemma' has the required type *) noextract let gcm256_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm256_pre s iv) (gcm256_post s iv)) (gcm256_lemma' s iv) noextract let code_gcm256 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_256 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm256_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm256 dom [] _ _ (W.mk_prediction code_gcm256 dom [] ((gcm256_lemma s iv) code_gcm256 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm256 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm256_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm256 dom (W.mk_prediction code_gcm256 dom [] ((gcm256_lemma s iv) code_gcm256 IA.win)) [@ (CCConv "stdcall") ]
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm128_decrypt_opt : Vale.Interop.Base.normal ( s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm128_t s iv)
[]
Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_decrypt_opt
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Interop.Base.normal ( s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm128_t s iv)
{ "end_col": 209, "end_line": 400, "start_col": 4, "start_line": 400 }
Prims.Tot
val lowstar_gcm128 (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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_gcm128 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win))
val lowstar_gcm128 (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv let lowstar_gcm128 (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv =
false
null
false
assert_norm (List.length dom + List.length ([] <: list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win))
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Interop.X64.wrap_weak_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.code_gcm128", "Vale.Stdcalls.X64.GCMdecryptOpt.dom", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Vale.Interop.X64.max_stdcall", "Vale.Interop.X64.arg_reg_stdcall", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Interop.X64.regs_modified_stdcall", "Vale.Interop.X64.xmms_modified_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_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", "Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm128_t" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* And here's the gcm wrapper itself *) noextract
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowstar_gcm128 (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv
[]
Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm128
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm128_t s iv
{ "end_col": 81, "end_line": 224, "start_col": 2, "start_line": 220 }
Prims.Tot
val lowstar_gcm256 (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) : lowstar_gcm256_t s iv
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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_gcm256 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm256_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm256 dom (W.mk_prediction code_gcm256 dom [] ((gcm256_lemma s iv) code_gcm256 IA.win))
val lowstar_gcm256 (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) : lowstar_gcm256_t s iv let lowstar_gcm256 (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) : lowstar_gcm256_t s iv =
false
null
false
assert_norm (List.length dom + List.length ([] <: list arg) <= 20); IX64.wrap_weak_stdcall code_gcm256 dom (W.mk_prediction code_gcm256 dom [] ((gcm256_lemma s iv) code_gcm256 IA.win))
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Interop.X64.wrap_weak_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.code_gcm256", "Vale.Stdcalls.X64.GCMdecryptOpt.dom", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Vale.Interop.X64.max_stdcall", "Vale.Interop.X64.arg_reg_stdcall", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Interop.X64.regs_modified_stdcall", "Vale.Interop.X64.xmms_modified_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_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", "Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm256_t" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm128 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm256_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm256_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm256_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm256_lemma' has the required type *) noextract let gcm256_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm256_pre s iv) (gcm256_post s iv)) (gcm256_lemma' s iv) noextract let code_gcm256 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_256 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm256_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm256 dom [] _ _ (W.mk_prediction code_gcm256 dom [] ((gcm256_lemma s iv) code_gcm256 IA.win)) (* And here's the gcm wrapper itself *) noextract
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowstar_gcm256 (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) : lowstar_gcm256_t s iv
[]
Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm256
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm256_t s iv
{ "end_col": 81, "end_line": 396, "start_col": 2, "start_line": 392 }
Prims.Tot
val gcm128_pre: (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s)
val gcm128_pre: (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom let gcm128_pre: (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom =
false
null
false
fun (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (c: V.va_code) (auth_b: b128) (auth_bytes: uint64) (auth_num: uint64) (keys_b: b128) (iv_b: b128) (hkeys_b: b128) (abytes_b: b128) (in128x6_b: b128) (out128x6_b: b128) (len128x6_num: uint64) (in128_b: b128) (out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b: b128) (tag_b: b128) (va_s0: V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s)
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.X64.Decls.va_code", "Vale.Stdcalls.X64.GCMdecryptOpt.b128", "Vale.Stdcalls.X64.GCMdecryptOpt.uint64", "Vale.X64.Decls.va_state", "Vale.AES.X64.GCMdecryptOpt.va_req_Gcm_blocks_decrypt_stdcall", "Vale.Interop.Assumptions.win", "Vale.AES.AES_common_s.AES_128", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "FStar.UInt64.v", "FStar.Ghost.reveal", "Prims.prop" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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 gcm128_pre: (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom
[]
Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_pre
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Words_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.GCMdecryptOpt.dom
{ "end_col": 74, "end_line": 87, "start_col": 2, "start_line": 57 }
Prims.Tot
val gcm128_post: Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f
val gcm128_post: Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom let gcm128_post: Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom =
false
null
false
fun (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (c: V.va_code) (auth_b: b128) (auth_bytes: uint64) (auth_num: uint64) (keys_b: b128) (iv_b: b128) (hkeys_b: b128) (abytes_b: b128) (in128x6_b: b128) (out128x6_b: b128) (len128x6_num: uint64) (in128_b: b128) (out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b: b128) (tag_b: b128) (va_s0: V.va_state) (va_s1: V.va_state) (f: V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.X64.Decls.va_code", "Vale.Stdcalls.X64.GCMdecryptOpt.b128", "Vale.Stdcalls.X64.GCMdecryptOpt.uint64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.AES.X64.GCMdecryptOpt.va_ens_Gcm_blocks_decrypt_stdcall", "Vale.Interop.Assumptions.win", "Vale.AES.AES_common_s.AES_128", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "FStar.UInt64.v", "FStar.Ghost.reveal", "Prims.prop" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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 gcm128_post: Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom
[]
Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_post
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Words_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.GCMdecryptOpt.dom
{ "end_col": 30, "end_line": 123, "start_col": 2, "start_line": 91 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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_gcm256_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm256 dom [] _ _ (W.mk_prediction code_gcm256 dom [] ((gcm256_lemma s iv) code_gcm256 IA.win))
let lowstar_gcm256_t (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) =
false
null
false
assert_norm (List.length dom + List.length ([] <: list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm256 dom [] _ _ (W.mk_prediction code_gcm256 dom [] ((gcm256_lemma s iv) code_gcm256 IA.win))
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Interop.X64.as_lowstar_sig_t_weak_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.code_gcm256", "Vale.Stdcalls.X64.GCMdecryptOpt.dom", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Vale.Interop.X64.max_stdcall", "Vale.Interop.X64.arg_reg_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Interop.X64.regs_modified_stdcall", "Vale.Interop.X64.xmms_modified_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_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.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm128 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm256_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm256_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm256_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm256_lemma' has the required type *) noextract let gcm256_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm256_pre s iv) (gcm256_post s iv)) (gcm256_lemma' s iv) noextract let code_gcm256 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_256 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowstar_gcm256_t : s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Type0
[]
Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm256_t
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Type0
{ "end_col": 81, "end_line": 387, "start_col": 2, "start_line": 380 }
Prims.Tot
val gcm256_post: Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 gcm256_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f
val gcm256_post: Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom let gcm256_post: Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom =
false
null
false
fun (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (c: V.va_code) (auth_b: b128) (auth_bytes: uint64) (auth_num: uint64) (keys_b: b128) (iv_b: b128) (hkeys_b: b128) (abytes_b: b128) (in128x6_b: b128) (out128x6_b: b128) (len128x6_num: uint64) (in128_b: b128) (out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b: b128) (tag_b: b128) (va_s0: V.va_state) (va_s1: V.va_state) (f: V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.X64.Decls.va_code", "Vale.Stdcalls.X64.GCMdecryptOpt.b128", "Vale.Stdcalls.X64.GCMdecryptOpt.uint64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.AES.X64.GCMdecryptOpt.va_ens_Gcm_blocks_decrypt_stdcall", "Vale.Interop.Assumptions.win", "Vale.AES.AES_common_s.AES_256", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "FStar.UInt64.v", "FStar.Ghost.reveal", "Prims.prop" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm128 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm256_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm256_post: Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom
[]
Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_post
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Words_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.GCMdecryptOpt.dom
{ "end_col": 30, "end_line": 295, "start_col": 2, "start_line": 263 }
Prims.Tot
val gcm256_pre: (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 gcm256_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s)
val gcm256_pre: (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom let gcm256_pre: (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom =
false
null
false
fun (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (c: V.va_code) (auth_b: b128) (auth_bytes: uint64) (auth_num: uint64) (keys_b: b128) (iv_b: b128) (hkeys_b: b128) (abytes_b: b128) (in128x6_b: b128) (out128x6_b: b128) (len128x6_num: uint64) (in128_b: b128) (out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b: b128) (tag_b: b128) (va_s0: V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s)
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.X64.Decls.va_code", "Vale.Stdcalls.X64.GCMdecryptOpt.b128", "Vale.Stdcalls.X64.GCMdecryptOpt.uint64", "Vale.X64.Decls.va_state", "Vale.AES.X64.GCMdecryptOpt.va_req_Gcm_blocks_decrypt_stdcall", "Vale.Interop.Assumptions.win", "Vale.AES.AES_common_s.AES_256", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "FStar.UInt64.v", "FStar.Ghost.reveal", "Prims.prop" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm128 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract
false
true
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm256_pre: (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom
[]
Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_pre
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Words_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.GCMdecryptOpt.dom
{ "end_col": 74, "end_line": 259, "start_col": 2, "start_line": 229 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv)
let gcm128_lemma (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) =
false
null
false
as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv)
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Stdcalls.X64.GCMdecryptOpt.as_t", "Vale.AsLowStar.ValeSig.vale_sig_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.dom", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_pre", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_post", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_lemma'" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *)
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm128_lemma : s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.AsLowStar.ValeSig.vale_sig_stdcall (Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_pre s iv) (Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_post s iv)
[]
Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_lemma
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.AsLowStar.ValeSig.vale_sig_stdcall (Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_pre s iv) (Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_post s iv)
{ "end_col": 173, "end_line": 200, "start_col": 86, "start_line": 200 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 gcm256_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm256_pre s iv) (gcm256_post s iv)) (gcm256_lemma' s iv)
let gcm256_lemma (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) =
false
null
false
as_t #(VSig.vale_sig_stdcall (gcm256_pre s iv) (gcm256_post s iv)) (gcm256_lemma' s iv)
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Stdcalls.X64.GCMdecryptOpt.as_t", "Vale.AsLowStar.ValeSig.vale_sig_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.dom", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_pre", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_post", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_lemma'" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm128 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm256_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm256_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm256_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm256_lemma' has the required type *)
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm256_lemma : s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.AsLowStar.ValeSig.vale_sig_stdcall (Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_pre s iv) (Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_post s iv)
[]
Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_lemma
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.AsLowStar.ValeSig.vale_sig_stdcall (Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_pre s iv) (Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_post s iv)
{ "end_col": 173, "end_line": 372, "start_col": 86, "start_line": 372 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 gcm256_decrypt_opt //: normal ((s:Ghost.erased (Seq.seq nat32)) -> lowstar_gcm256_t s) = as_normal_t #((s:Ghost.erased (Seq.seq nat32)) -> (iv:Ghost.erased supported_iv_LE) -> lowstar_gcm256_t s iv) (fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) -> lowstar_gcm256 s iv)
let gcm256_decrypt_opt =
false
null
false
as_normal_t #(s: Ghost.erased (Seq.seq nat32) -> iv: Ghost.erased supported_iv_LE -> lowstar_gcm256_t s iv) (fun (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) -> lowstar_gcm256 s iv)
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[ "total" ]
[ "Vale.Stdcalls.X64.GCMdecryptOpt.as_normal_t", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm256_t", "Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm256" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm128 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm256_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm256_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm256_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm256_lemma' has the required type *) noextract let gcm256_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm256_pre s iv) (gcm256_post s iv)) (gcm256_lemma' s iv) noextract let code_gcm256 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_256 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm256_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm256 dom [] _ _ (W.mk_prediction code_gcm256 dom [] ((gcm256_lemma s iv) code_gcm256 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm256 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm256_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm256 dom (W.mk_prediction code_gcm256 dom [] ((gcm256_lemma s iv) code_gcm256 IA.win)) [@ (CCConv "stdcall") ] let gcm128_decrypt_opt //: normal ((s:Ghost.erased (Seq.seq nat32)) -> lowstar_gcm128_t s) = as_normal_t #((s:Ghost.erased (Seq.seq nat32)) -> (iv:Ghost.erased supported_iv_LE) -> lowstar_gcm128_t s iv) (fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) -> lowstar_gcm128 s iv) [@ (CCConv "stdcall") ]
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm256_decrypt_opt : Vale.Interop.Base.normal ( s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm256_t s iv)
[]
Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_decrypt_opt
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.Interop.Base.normal ( s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm256_t s iv)
{ "end_col": 209, "end_line": 404, "start_col": 4, "start_line": 404 }
Prims.Ghost
val gcm128_lemma' (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (code: V.va_code) (_win: bool) (auth_b: b128) (auth_bytes auth_num: uint64) (keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b: b128) (len128x6_num: uint64) (in128_b out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b tag_b: b128) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b)))
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f
val gcm128_lemma' (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (code: V.va_code) (_win: bool) (auth_b: b128) (auth_bytes auth_num: uint64) (keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b: b128) (len128x6_num: uint64) (in128_b out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b tag_b: b128) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b))) let gcm128_lemma' (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (code: V.va_code) (_win: bool) (auth_b: b128) (auth_bytes auth_num: uint64) (keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b: b128) (len128x6_num: uint64) (in128_b out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b tag_b: b128) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b))) =
false
null
false
let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.X64.Decls.va_code", "Prims.bool", "Vale.Stdcalls.X64.GCMdecryptOpt.b128", "Vale.Stdcalls.X64.GCMdecryptOpt.uint64", "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.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.AES.X64.GCMdecryptOpt.va_lemma_Gcm_blocks_decrypt_stdcall", "Vale.Interop.Assumptions.win", "Vale.AES.AES_common_s.AES_128", "Vale.X64.MemoryAdapters.as_vale_buffer", "FStar.UInt64.v", "FStar.Ghost.reveal", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_pre", "Prims.l_and", "Vale.X64.Decls.eval_code", "Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_post", "Vale.X64.Memory.buffer_writeable" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm128_lemma' (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (code: V.va_code) (_win: bool) (auth_b: b128) (auth_bytes auth_num: uint64) (keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b: b128) (len128x6_num: uint64) (in128_b out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b tag_b: b128) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b)))
[]
Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_lemma'
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> code: Vale.X64.Decls.va_code -> _win: Prims.bool -> auth_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> auth_bytes: Vale.Stdcalls.X64.GCMdecryptOpt.uint64 -> auth_num: Vale.Stdcalls.X64.GCMdecryptOpt.uint64 -> keys_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> iv_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> hkeys_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> abytes_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> in128x6_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> out128x6_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> len128x6_num: Vale.Stdcalls.X64.GCMdecryptOpt.uint64 -> in128_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> out128_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> len128_num: Vale.Stdcalls.X64.GCMdecryptOpt.uint64 -> inout_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> cipher_num: Vale.Stdcalls.X64.GCMdecryptOpt.uint64 -> scratch_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> tag_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> va_s0: Vale.X64.Decls.va_state -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 11, "end_line": 196, "start_col": 5, "start_line": 172 }
Prims.Ghost
val gcm256_lemma' (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (code: V.va_code) (_win: bool) (auth_b: b128) (auth_bytes auth_num: uint64) (keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b: b128) (len128x6_num: uint64) (in128_b out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b tag_b: b128) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b)))
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMdecryptOpt", "short_module": "GC" }, { "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.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "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.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.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 gcm256_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f
val gcm256_lemma' (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (code: V.va_code) (_win: bool) (auth_b: b128) (auth_bytes auth_num: uint64) (keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b: b128) (len128x6_num: uint64) (in128_b out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b tag_b: b128) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b))) let gcm256_lemma' (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (code: V.va_code) (_win: bool) (auth_b: b128) (auth_bytes auth_num: uint64) (keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b: b128) (len128x6_num: uint64) (in128_b out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b tag_b: b128) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b))) =
false
null
false
let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f
{ "checked_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst.checked", "dependencies": [ "Vale.X64.State.fsti.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.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMdecryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Seq.fst.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.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCMdecryptOpt.fst" }
[]
[ "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.X64.Decls.va_code", "Prims.bool", "Vale.Stdcalls.X64.GCMdecryptOpt.b128", "Vale.Stdcalls.X64.GCMdecryptOpt.uint64", "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.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.AES.X64.GCMdecryptOpt.va_lemma_Gcm_blocks_decrypt_stdcall", "Vale.Interop.Assumptions.win", "Vale.AES.AES_common_s.AES_256", "Vale.X64.MemoryAdapters.as_vale_buffer", "FStar.UInt64.v", "FStar.Ghost.reveal", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_pre", "Prims.l_and", "Vale.X64.Decls.eval_code", "Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall", "Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_post", "Vale.X64.Memory.buffer_writeable" ]
[]
module Vale.Stdcalls.X64.GCMdecryptOpt open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up 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 GC = Vale.AES.X64.GCMdecryptOpt open Vale.AES.AES_s open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public}) [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_no_mod; t128_mod_pub; t128_no_mod; t128_no_mod; t128_no_mod; t128_mod; tuint64; t128_no_mod; t128_mod; tuint64; t128_mod; tuint64; t128_mod; t128_no_mod] in assert_norm (List.length y = 17); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm128_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm128_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm128_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm128_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm128_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b) )) = let va_s1, f = GC.va_lemma_Gcm_blocks_decrypt_stdcall code va_s0 IA.win AES_128 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 auth_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 abytes_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128x6_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out128_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 scratch_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 tag_b; va_s1, f (* Prove that gcm128_lemma' has the required type *) noextract let gcm128_lemma (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (gcm128_pre s iv) (gcm128_post s iv)) (gcm128_lemma' s iv) noextract let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128 (* Here's the type expected for the gcm wrapper *) [@__reduce__] noextract let lowstar_gcm128_t (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_gcm128 dom [] _ _ (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_gcm128 (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_gcm128 dom (W.mk_prediction code_gcm128 dom [] ((gcm128_lemma s iv) code_gcm128 IA.win)) (* Need to rearrange the order of arguments *) [@__reduce__] noextract let gcm256_pre : (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) -> GC.va_req_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) [@__reduce__] noextract let gcm256_post : Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Gcm_blocks_decrypt_stdcall c va_s0 IA.win AES_256 (as_vale_buffer auth_b) (UInt64.v auth_bytes) (UInt64.v auth_num) (as_vale_buffer keys_b) (as_vale_buffer iv_b) (Ghost.reveal iv) (as_vale_buffer hkeys_b) (as_vale_buffer abytes_b) (as_vale_buffer in128x6_b) (as_vale_buffer out128x6_b) (UInt64.v len128x6_num) (as_vale_buffer in128_b) (as_vale_buffer out128_b) (UInt64.v len128_num) (as_vale_buffer inout_b) (UInt64.v cipher_num) (as_vale_buffer scratch_b) (as_vale_buffer tag_b) (Ghost.reveal s) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let gcm256_lemma' (s:Ghost.erased (Seq.seq nat32)) (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (auth_b:b128) (auth_bytes:uint64) (auth_num:uint64) (keys_b:b128) (iv_b:b128) (hkeys_b:b128) (abytes_b:b128) (in128x6_b:b128) (out128x6_b:b128) (len128x6_num:uint64) (in128_b:b128) (out128_b:b128) (len128_num:uint64) (inout_b:b128) (cipher_num:uint64) (scratch_b:b128) (tag_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\
false
false
Vale.Stdcalls.X64.GCMdecryptOpt.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm256_lemma' (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) (code: V.va_code) (_win: bool) (auth_b: b128) (auth_bytes auth_num: uint64) (keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b: b128) (len128x6_num: uint64) (in128_b out128_b: b128) (len128_num: uint64) (inout_b: b128) (cipher_num: uint64) (scratch_b tag_b: b128) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires gcm256_pre s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ gcm256_post s iv code auth_b auth_bytes auth_num keys_b iv_b hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer auth_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer abytes_b) /\ ME.buffer_writeable (as_vale_buffer in128x6_b) /\ ME.buffer_writeable (as_vale_buffer out128x6_b) /\ ME.buffer_writeable (as_vale_buffer in128_b) /\ ME.buffer_writeable (as_vale_buffer out128_b) /\ ME.buffer_writeable (as_vale_buffer inout_b) /\ ME.buffer_writeable (as_vale_buffer scratch_b) /\ ME.buffer_writeable (as_vale_buffer tag_b)))
[]
Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_lemma'
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> code: Vale.X64.Decls.va_code -> _win: Prims.bool -> auth_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> auth_bytes: Vale.Stdcalls.X64.GCMdecryptOpt.uint64 -> auth_num: Vale.Stdcalls.X64.GCMdecryptOpt.uint64 -> keys_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> iv_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> hkeys_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> abytes_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> in128x6_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> out128x6_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> len128x6_num: Vale.Stdcalls.X64.GCMdecryptOpt.uint64 -> in128_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> out128_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> len128_num: Vale.Stdcalls.X64.GCMdecryptOpt.uint64 -> inout_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> cipher_num: Vale.Stdcalls.X64.GCMdecryptOpt.uint64 -> scratch_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> tag_b: Vale.Stdcalls.X64.GCMdecryptOpt.b128 -> va_s0: Vale.X64.Decls.va_state -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
{ "end_col": 11, "end_line": 368, "start_col": 5, "start_line": 344 }
Prims.GTot
val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 buffer_region_of #a v = B.frameOf v
val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v =
false
null
false
B.frameOf v
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "sometrivial" ]
[ "LowStar.Buffer.buffer", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Buffer.trivial_preorder", "FStar.Monotonic.HyperHeap.rid" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid
false
false
LowStar.Regional.Instances.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 buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid
[]
LowStar.Regional.Instances.buffer_region_of
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
v: LowStar.Buffer.buffer a -> Prims.GTot FStar.Monotonic.HyperHeap.rid
{ "end_col": 13, "end_line": 36, "start_col": 2, "start_line": 36 }
Prims.Tot
val buffer_dummy: a:Type -> Tot (B.buffer a)
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 buffer_dummy _ = B.null
val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ =
false
null
false
B.null
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "total" ]
[ "LowStar.Buffer.null", "LowStar.Buffer.buffer" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v
false
false
LowStar.Regional.Instances.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 buffer_dummy: a:Type -> Tot (B.buffer a)
[]
LowStar.Regional.Instances.buffer_dummy
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type0 -> LowStar.Buffer.buffer a
{ "end_col": 27, "end_line": 39, "start_col": 21, "start_line": 39 }
Prims.GTot
val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len
val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v =
false
null
false
B.live h v /\ B.freeable v /\ B.len v == len
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "sometrivial" ]
[ "LowStar.Regional.Instances.nonzero", "FStar.Monotonic.HyperStack.mem", "LowStar.Buffer.buffer", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.freeable", "Prims.eq2", "FStar.UInt32.t", "LowStar.Monotonic.Buffer.len" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0
false
false
LowStar.Regional.Instances.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 buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0
[]
LowStar.Regional.Instances.buffer_r_inv
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
len: LowStar.Regional.Instances.nonzero -> h: FStar.Monotonic.HyperStack.mem -> v: LowStar.Buffer.buffer a -> Prims.GTot Type0
{ "end_col": 16, "end_line": 48, "start_col": 2, "start_line": 47 }
Prims.Tot
val vector_irepr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Ghost.erased (vector_repr rg)
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 vector_irepr #a #rst rg = Ghost.hide S.empty
val vector_irepr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Ghost.erased (vector_repr rg) let vector_irepr #a #rst rg =
false
null
false
Ghost.hide S.empty
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "total" ]
[ "LowStar.Regional.regional", "FStar.Ghost.hide", "LowStar.Regional.Instances.vector_repr", "FStar.Seq.Base.empty", "LowStar.Regional.__proj__Rgl__item__repr", "FStar.Ghost.erased" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v = B.free v val buffer_copy: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero){ arg == Ghost.reveal arg' } -> src:B.buffer a -> dst:B.buffer a -> HST.ST unit (requires (fun h0 -> let len = snd arg in buffer_r_inv len h0 src /\ buffer_r_inv len h0 dst /\ HS.disjoint (buffer_region_of src) (buffer_region_of dst))) (ensures (fun h0 _ h1 -> let len = snd arg in modifies (loc_all_regions_from false (buffer_region_of dst)) h0 h1 /\ buffer_r_inv len h1 dst /\ buffer_r_repr len h1 dst == buffer_r_repr len h0 src)) let buffer_copy #a #_ (ia, len) src dst = B.blit src 0ul dst 0ul len #set-options "--print_implicits" val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a) let buffer_regional #a ia len = Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) // This is key: there is no partial application here, meaning this extracts to C. (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len)) val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len) let buffer_copyable #a ia len = Cpy (buffer_copy #_ #(ia, len)) /// If `a` is regional, then `vector a` is also regional. /// /// We keep a pointer at run-time to the parent type-class. val vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid let vector_region_of #a #rst rg v = V.frameOf v val vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg) let vector_dummy #a #_ _ = V.alloc_empty a val vector_r_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> GTot Type0 let vector_r_inv #a #rst rg h v = RV.rv_inv h v val vector_r_inv_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> Lemma (requires (vector_r_inv rg h v)) (ensures (HS.live_region h (vector_region_of rg v))) let vector_r_inv_reg #a #rst rg h v = () val vector_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Tot Type0 let vector_repr #a #rst rg = S.seq (Rgl?.repr rg) val vector_r_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg{vector_r_inv rg h v} -> GTot (vector_repr rg) let vector_r_repr #a #rst rg h v = RV.as_seq h v val vector_r_sep: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (vector_r_inv rg h0 v /\ loc_disjoint (loc_all_regions_from false (vector_region_of rg v)) p /\ modifies p h0 h1)) (ensures (vector_r_inv rg h1 v /\ vector_r_repr rg h0 v == vector_r_repr rg h1 v)) let vector_r_sep #a #rst rg v p h0 h1 = RV.rv_inv_preserved v p h0 h1; RV.as_seq_preserved v p h0 h1 val vector_irepr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Ghost.erased (vector_repr rg)
false
false
LowStar.Regional.Instances.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 vector_irepr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Ghost.erased (vector_repr rg)
[]
LowStar.Regional.Instances.vector_irepr
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
rg: LowStar.Regional.regional rst a -> FStar.Ghost.erased (LowStar.Regional.Instances.vector_repr rg)
{ "end_col": 20, "end_line": 229, "start_col": 2, "start_line": 229 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 nonzero = len:UInt32.t{len > 0ul}
let nonzero =
false
null
false
len: UInt32.t{len > 0ul}
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.b2t", "FStar.Integers.op_Greater", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.UInt32.__uint_to_t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null
false
true
LowStar.Regional.Instances.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 nonzero : Type0
[]
LowStar.Regional.Instances.nonzero
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Type0
{ "end_col": 37, "end_line": 41, "start_col": 14, "start_line": 41 }
Prims.Tot
val vector_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Tot Type0
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 vector_repr #a #rst rg = S.seq (Rgl?.repr rg)
val vector_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Tot Type0 let vector_repr #a #rst rg =
false
null
false
S.seq (Rgl?.repr rg)
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "total" ]
[ "LowStar.Regional.regional", "FStar.Seq.Base.seq", "LowStar.Regional.__proj__Rgl__item__repr" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v = B.free v val buffer_copy: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero){ arg == Ghost.reveal arg' } -> src:B.buffer a -> dst:B.buffer a -> HST.ST unit (requires (fun h0 -> let len = snd arg in buffer_r_inv len h0 src /\ buffer_r_inv len h0 dst /\ HS.disjoint (buffer_region_of src) (buffer_region_of dst))) (ensures (fun h0 _ h1 -> let len = snd arg in modifies (loc_all_regions_from false (buffer_region_of dst)) h0 h1 /\ buffer_r_inv len h1 dst /\ buffer_r_repr len h1 dst == buffer_r_repr len h0 src)) let buffer_copy #a #_ (ia, len) src dst = B.blit src 0ul dst 0ul len #set-options "--print_implicits" val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a) let buffer_regional #a ia len = Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) // This is key: there is no partial application here, meaning this extracts to C. (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len)) val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len) let buffer_copyable #a ia len = Cpy (buffer_copy #_ #(ia, len)) /// If `a` is regional, then `vector a` is also regional. /// /// We keep a pointer at run-time to the parent type-class. val vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid let vector_region_of #a #rst rg v = V.frameOf v val vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg) let vector_dummy #a #_ _ = V.alloc_empty a val vector_r_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> GTot Type0 let vector_r_inv #a #rst rg h v = RV.rv_inv h v val vector_r_inv_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> Lemma (requires (vector_r_inv rg h v)) (ensures (HS.live_region h (vector_region_of rg v))) let vector_r_inv_reg #a #rst rg h v = ()
false
false
LowStar.Regional.Instances.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 vector_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Tot Type0
[]
LowStar.Regional.Instances.vector_repr
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
rg: LowStar.Regional.regional rst a -> Type0
{ "end_col": 49, "end_line": 204, "start_col": 29, "start_line": 204 }
Prims.Tot
val vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg)
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 vector_dummy #a #_ _ = V.alloc_empty a
val vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg) let vector_dummy #a #_ _ =
false
null
false
V.alloc_empty a
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "total" ]
[ "FStar.Ghost.erased", "LowStar.Regional.regional", "LowStar.Vector.alloc_empty", "LowStar.RVector.rvector", "FStar.Ghost.reveal" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v = B.free v val buffer_copy: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero){ arg == Ghost.reveal arg' } -> src:B.buffer a -> dst:B.buffer a -> HST.ST unit (requires (fun h0 -> let len = snd arg in buffer_r_inv len h0 src /\ buffer_r_inv len h0 dst /\ HS.disjoint (buffer_region_of src) (buffer_region_of dst))) (ensures (fun h0 _ h1 -> let len = snd arg in modifies (loc_all_regions_from false (buffer_region_of dst)) h0 h1 /\ buffer_r_inv len h1 dst /\ buffer_r_repr len h1 dst == buffer_r_repr len h0 src)) let buffer_copy #a #_ (ia, len) src dst = B.blit src 0ul dst 0ul len #set-options "--print_implicits" val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a) let buffer_regional #a ia len = Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) // This is key: there is no partial application here, meaning this extracts to C. (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len)) val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len) let buffer_copyable #a ia len = Cpy (buffer_copy #_ #(ia, len)) /// If `a` is regional, then `vector a` is also regional. /// /// We keep a pointer at run-time to the parent type-class. val vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid let vector_region_of #a #rst rg v = V.frameOf v val vector_dummy:
false
false
LowStar.Regional.Instances.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 vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg)
[]
LowStar.Regional.Instances.vector_dummy
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
rg: FStar.Ghost.erased (LowStar.Regional.regional rst a) -> LowStar.RVector.rvector (FStar.Ghost.reveal rg)
{ "end_col": 42, "end_line": 189, "start_col": 27, "start_line": 189 }
Prims.GTot
val vector_r_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> GTot Type0
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 vector_r_inv #a #rst rg h v = RV.rv_inv h v
val vector_r_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> GTot Type0 let vector_r_inv #a #rst rg h v =
false
null
false
RV.rv_inv h v
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "sometrivial" ]
[ "LowStar.Regional.regional", "FStar.Monotonic.HyperStack.mem", "LowStar.RVector.rvector", "LowStar.RVector.rv_inv" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v = B.free v val buffer_copy: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero){ arg == Ghost.reveal arg' } -> src:B.buffer a -> dst:B.buffer a -> HST.ST unit (requires (fun h0 -> let len = snd arg in buffer_r_inv len h0 src /\ buffer_r_inv len h0 dst /\ HS.disjoint (buffer_region_of src) (buffer_region_of dst))) (ensures (fun h0 _ h1 -> let len = snd arg in modifies (loc_all_regions_from false (buffer_region_of dst)) h0 h1 /\ buffer_r_inv len h1 dst /\ buffer_r_repr len h1 dst == buffer_r_repr len h0 src)) let buffer_copy #a #_ (ia, len) src dst = B.blit src 0ul dst 0ul len #set-options "--print_implicits" val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a) let buffer_regional #a ia len = Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) // This is key: there is no partial application here, meaning this extracts to C. (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len)) val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len) let buffer_copyable #a ia len = Cpy (buffer_copy #_ #(ia, len)) /// If `a` is regional, then `vector a` is also regional. /// /// We keep a pointer at run-time to the parent type-class. val vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid let vector_region_of #a #rst rg v = V.frameOf v val vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg) let vector_dummy #a #_ _ = V.alloc_empty a val vector_r_inv: #a:Type0 -> #rst:Type -> rg:regional rst a ->
false
false
LowStar.Regional.Instances.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 vector_r_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> GTot Type0
[]
LowStar.Regional.Instances.vector_r_inv
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
rg: LowStar.Regional.regional rst a -> h: FStar.Monotonic.HyperStack.mem -> v: LowStar.RVector.rvector rg -> Prims.GTot Type0
{ "end_col": 47, "end_line": 194, "start_col": 34, "start_line": 194 }
Prims.GTot
val vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 vector_region_of #a #rst rg v = V.frameOf v
val vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid let vector_region_of #a #rst rg v =
false
null
false
V.frameOf v
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "sometrivial" ]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "LowStar.Vector.frameOf", "FStar.Monotonic.HyperHeap.rid" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v = B.free v val buffer_copy: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero){ arg == Ghost.reveal arg' } -> src:B.buffer a -> dst:B.buffer a -> HST.ST unit (requires (fun h0 -> let len = snd arg in buffer_r_inv len h0 src /\ buffer_r_inv len h0 dst /\ HS.disjoint (buffer_region_of src) (buffer_region_of dst))) (ensures (fun h0 _ h1 -> let len = snd arg in modifies (loc_all_regions_from false (buffer_region_of dst)) h0 h1 /\ buffer_r_inv len h1 dst /\ buffer_r_repr len h1 dst == buffer_r_repr len h0 src)) let buffer_copy #a #_ (ia, len) src dst = B.blit src 0ul dst 0ul len #set-options "--print_implicits" val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a) let buffer_regional #a ia len = Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) // This is key: there is no partial application here, meaning this extracts to C. (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len)) val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len) let buffer_copyable #a ia len = Cpy (buffer_copy #_ #(ia, len)) /// If `a` is regional, then `vector a` is also regional. /// /// We keep a pointer at run-time to the parent type-class. val vector_region_of:
false
false
LowStar.Regional.Instances.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 vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid
[]
LowStar.Regional.Instances.vector_region_of
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
rg: LowStar.Regional.regional rst a -> v: LowStar.RVector.rvector rg -> Prims.GTot FStar.Monotonic.HyperHeap.rid
{ "end_col": 47, "end_line": 185, "start_col": 36, "start_line": 185 }
Prims.GTot
val vector_r_alloc_p: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot Type0
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 vector_r_alloc_p #a #rst rg v = V.size_of v = 0ul
val vector_r_alloc_p: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot Type0 let vector_r_alloc_p #a #rst rg v =
false
null
false
V.size_of v = 0ul
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "sometrivial" ]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "Prims.b2t", "Prims.op_Equality", "FStar.UInt32.t", "LowStar.Vector.size_of", "FStar.UInt32.__uint_to_t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v = B.free v val buffer_copy: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero){ arg == Ghost.reveal arg' } -> src:B.buffer a -> dst:B.buffer a -> HST.ST unit (requires (fun h0 -> let len = snd arg in buffer_r_inv len h0 src /\ buffer_r_inv len h0 dst /\ HS.disjoint (buffer_region_of src) (buffer_region_of dst))) (ensures (fun h0 _ h1 -> let len = snd arg in modifies (loc_all_regions_from false (buffer_region_of dst)) h0 h1 /\ buffer_r_inv len h1 dst /\ buffer_r_repr len h1 dst == buffer_r_repr len h0 src)) let buffer_copy #a #_ (ia, len) src dst = B.blit src 0ul dst 0ul len #set-options "--print_implicits" val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a) let buffer_regional #a ia len = Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) // This is key: there is no partial application here, meaning this extracts to C. (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len)) val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len) let buffer_copyable #a ia len = Cpy (buffer_copy #_ #(ia, len)) /// If `a` is regional, then `vector a` is also regional. /// /// We keep a pointer at run-time to the parent type-class. val vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid let vector_region_of #a #rst rg v = V.frameOf v val vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg) let vector_dummy #a #_ _ = V.alloc_empty a val vector_r_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> GTot Type0 let vector_r_inv #a #rst rg h v = RV.rv_inv h v val vector_r_inv_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> Lemma (requires (vector_r_inv rg h v)) (ensures (HS.live_region h (vector_region_of rg v))) let vector_r_inv_reg #a #rst rg h v = () val vector_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Tot Type0 let vector_repr #a #rst rg = S.seq (Rgl?.repr rg) val vector_r_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg{vector_r_inv rg h v} -> GTot (vector_repr rg) let vector_r_repr #a #rst rg h v = RV.as_seq h v val vector_r_sep: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (vector_r_inv rg h0 v /\ loc_disjoint (loc_all_regions_from false (vector_region_of rg v)) p /\ modifies p h0 h1)) (ensures (vector_r_inv rg h1 v /\ vector_r_repr rg h0 v == vector_r_repr rg h1 v)) let vector_r_sep #a #rst rg v p h0 h1 = RV.rv_inv_preserved v p h0 h1; RV.as_seq_preserved v p h0 h1 val vector_irepr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Ghost.erased (vector_repr rg) let vector_irepr #a #rst rg = Ghost.hide S.empty val vector_r_alloc_p: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot Type0
false
false
LowStar.Regional.Instances.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 vector_r_alloc_p: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot Type0
[]
LowStar.Regional.Instances.vector_r_alloc_p
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
rg: LowStar.Regional.regional rst a -> v: LowStar.RVector.rvector rg -> Prims.GTot Type0
{ "end_col": 19, "end_line": 234, "start_col": 2, "start_line": 234 }
Prims.GTot
val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 buffer_r_alloc_p #a v = True
val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v =
false
null
false
True
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "sometrivial" ]
[ "LowStar.Buffer.buffer", "Prims.l_True" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0
false
false
LowStar.Regional.Instances.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 buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0
[]
LowStar.Regional.Instances.buffer_r_alloc_p
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
v: LowStar.Buffer.buffer a -> Prims.GTot Type0
{ "end_col": 6, "end_line": 90, "start_col": 2, "start_line": 90 }
Prims.Tot
val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 buffer_repr a len = s:S.seq a{S.length s = len}
val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len =
false
null
false
s: S.seq a {S.length s = len}
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "total" ]
[ "FStar.Integers.nat", "Prims.b2t", "FStar.Integers.op_Greater", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.Seq.Base.seq", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Prims.l_and", "FStar.Integers.op_Greater_Equals", "FStar.Seq.Base.length" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = ()
false
false
LowStar.Regional.Instances.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 buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0
[]
LowStar.Regional.Instances.buffer_repr
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type0 -> len: FStar.Integers.nat{len > 0} -> Type0
{ "end_col": 51, "end_line": 58, "start_col": 24, "start_line": 58 }
Prims.GTot
val vector_r_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg{vector_r_inv rg h v} -> GTot (vector_repr rg)
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 vector_r_repr #a #rst rg h v = RV.as_seq h v
val vector_r_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg{vector_r_inv rg h v} -> GTot (vector_repr rg) let vector_r_repr #a #rst rg h v =
false
null
false
RV.as_seq h v
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "sometrivial" ]
[ "LowStar.Regional.regional", "FStar.Monotonic.HyperStack.mem", "LowStar.RVector.rvector", "LowStar.Regional.Instances.vector_r_inv", "LowStar.RVector.as_seq", "LowStar.Regional.Instances.vector_repr" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v = B.free v val buffer_copy: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero){ arg == Ghost.reveal arg' } -> src:B.buffer a -> dst:B.buffer a -> HST.ST unit (requires (fun h0 -> let len = snd arg in buffer_r_inv len h0 src /\ buffer_r_inv len h0 dst /\ HS.disjoint (buffer_region_of src) (buffer_region_of dst))) (ensures (fun h0 _ h1 -> let len = snd arg in modifies (loc_all_regions_from false (buffer_region_of dst)) h0 h1 /\ buffer_r_inv len h1 dst /\ buffer_r_repr len h1 dst == buffer_r_repr len h0 src)) let buffer_copy #a #_ (ia, len) src dst = B.blit src 0ul dst 0ul len #set-options "--print_implicits" val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a) let buffer_regional #a ia len = Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) // This is key: there is no partial application here, meaning this extracts to C. (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len)) val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len) let buffer_copyable #a ia len = Cpy (buffer_copy #_ #(ia, len)) /// If `a` is regional, then `vector a` is also regional. /// /// We keep a pointer at run-time to the parent type-class. val vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid let vector_region_of #a #rst rg v = V.frameOf v val vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg) let vector_dummy #a #_ _ = V.alloc_empty a val vector_r_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> GTot Type0 let vector_r_inv #a #rst rg h v = RV.rv_inv h v val vector_r_inv_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> Lemma (requires (vector_r_inv rg h v)) (ensures (HS.live_region h (vector_region_of rg v))) let vector_r_inv_reg #a #rst rg h v = () val vector_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Tot Type0 let vector_repr #a #rst rg = S.seq (Rgl?.repr rg) val vector_r_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg{vector_r_inv rg h v} ->
false
false
LowStar.Regional.Instances.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 vector_r_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg{vector_r_inv rg h v} -> GTot (vector_repr rg)
[]
LowStar.Regional.Instances.vector_r_repr
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
rg: LowStar.Regional.regional rst a -> h: FStar.Monotonic.HyperStack.mem -> v: LowStar.RVector.rvector rg {LowStar.Regional.Instances.vector_r_inv rg h v} -> Prims.GTot (LowStar.Regional.Instances.vector_repr rg)
{ "end_col": 48, "end_line": 210, "start_col": 35, "start_line": 210 }
FStar.HyperStack.ST.ST
val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1))
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 buffer_r_free #a len v = B.free v
val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v =
true
null
false
B.free v
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[]
[ "FStar.Ghost.erased", "FStar.Pervasives.Native.tuple2", "LowStar.Regional.Instances.nonzero", "Prims.eq2", "FStar.Ghost.reveal", "LowStar.Buffer.buffer", "LowStar.Monotonic.Buffer.free", "LowStar.Buffer.trivial_preorder", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1))
false
false
LowStar.Regional.Instances.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 buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1))
[]
LowStar.Regional.Instances.buffer_r_free
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
arg: (a * LowStar.Regional.Instances.nonzero) {arg == FStar.Ghost.reveal arg'} -> v: LowStar.Buffer.buffer a -> FStar.HyperStack.ST.ST Prims.unit
{ "end_col": 10, "end_line": 131, "start_col": 2, "start_line": 131 }
Prims.Tot
val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len)
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 buffer_copyable #a ia len = Cpy (buffer_copy #_ #(ia, len))
val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len) let buffer_copyable #a ia len =
false
null
false
Cpy (buffer_copy #_ #(ia, len))
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "total" ]
[ "LowStar.Regional.Instances.nonzero", "LowStar.RVector.Cpy", "FStar.Pervasives.Native.tuple2", "LowStar.Buffer.buffer", "LowStar.Regional.Instances.buffer_regional", "LowStar.Regional.Instances.buffer_copy", "FStar.Ghost.hide", "FStar.Pervasives.Native.Mktuple2", "LowStar.RVector.copyable" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v = B.free v val buffer_copy: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero){ arg == Ghost.reveal arg' } -> src:B.buffer a -> dst:B.buffer a -> HST.ST unit (requires (fun h0 -> let len = snd arg in buffer_r_inv len h0 src /\ buffer_r_inv len h0 dst /\ HS.disjoint (buffer_region_of src) (buffer_region_of dst))) (ensures (fun h0 _ h1 -> let len = snd arg in modifies (loc_all_regions_from false (buffer_region_of dst)) h0 h1 /\ buffer_r_inv len h1 dst /\ buffer_r_repr len h1 dst == buffer_r_repr len h0 src)) let buffer_copy #a #_ (ia, len) src dst = B.blit src 0ul dst 0ul len #set-options "--print_implicits" val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a) let buffer_regional #a ia len = Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) // This is key: there is no partial application here, meaning this extracts to C. (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len)) val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len)
false
false
LowStar.Regional.Instances.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 buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len)
[]
LowStar.Regional.Instances.buffer_copyable
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
ia: a -> len: LowStar.Regional.Instances.nonzero -> LowStar.RVector.copyable (LowStar.Buffer.buffer a) (LowStar.Regional.Instances.buffer_regional ia len)
{ "end_col": 33, "end_line": 177, "start_col": 2, "start_line": 177 }
Prims.Tot
val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a)
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 buffer_regional #a ia len = Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) // This is key: there is no partial application here, meaning this extracts to C. (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len))
val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a) let buffer_regional #a ia len =
false
null
false
Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len))
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "total" ]
[ "LowStar.Regional.Instances.nonzero", "LowStar.Regional.Rgl", "FStar.Pervasives.Native.tuple2", "LowStar.Buffer.buffer", "FStar.Pervasives.Native.Mktuple2", "LowStar.Regional.Instances.buffer_region_of", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Buffer.trivial_preorder", "LowStar.Regional.Instances.buffer_dummy", "LowStar.Regional.Instances.buffer_r_inv", "LowStar.Regional.Instances.buffer_r_inv_reg", "LowStar.Regional.Instances.buffer_repr", "FStar.UInt32.v", "LowStar.Regional.Instances.buffer_r_repr", "LowStar.Regional.Instances.buffer_r_sep", "LowStar.Regional.Instances.buffer_irepr", "LowStar.Regional.Instances.buffer_r_alloc_p", "LowStar.Regional.Instances.buffer_r_alloc", "FStar.Ghost.hide", "LowStar.Regional.Instances.buffer_r_free", "LowStar.Regional.regional" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v = B.free v val buffer_copy: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero){ arg == Ghost.reveal arg' } -> src:B.buffer a -> dst:B.buffer a -> HST.ST unit (requires (fun h0 -> let len = snd arg in buffer_r_inv len h0 src /\ buffer_r_inv len h0 dst /\ HS.disjoint (buffer_region_of src) (buffer_region_of dst))) (ensures (fun h0 _ h1 -> let len = snd arg in modifies (loc_all_regions_from false (buffer_region_of dst)) h0 h1 /\ buffer_r_inv len h1 dst /\ buffer_r_repr len h1 dst == buffer_r_repr len h0 src)) let buffer_copy #a #_ (ia, len) src dst = B.blit src 0ul dst 0ul len #set-options "--print_implicits" val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a)
false
false
LowStar.Regional.Instances.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 buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a)
[]
LowStar.Regional.Instances.buffer_regional
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
ia: a -> len: LowStar.Regional.Instances.nonzero -> LowStar.Regional.regional (a * LowStar.Regional.Instances.nonzero) (LowStar.Buffer.buffer a)
{ "end_col": 35, "end_line": 169, "start_col": 2, "start_line": 156 }
FStar.HyperStack.ST.ST
val vector_r_free: #a:Type0 -> #rst:Type -> #rg:Ghost.erased (regional rst a) -> (s:regional rst a{s == Ghost.reveal rg}) -> v:rvector rg -> HST.ST unit (requires (fun h0 -> vector_r_inv rg h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (vector_region_of rg v)) h0 h1))
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 vector_r_free #_ #_ _ v = V.free v
val vector_r_free: #a:Type0 -> #rst:Type -> #rg:Ghost.erased (regional rst a) -> (s:regional rst a{s == Ghost.reveal rg}) -> v:rvector rg -> HST.ST unit (requires (fun h0 -> vector_r_inv rg h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (vector_region_of rg v)) h0 h1)) let vector_r_free #_ #_ _ v =
true
null
false
V.free v
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[]
[ "FStar.Ghost.erased", "LowStar.Regional.regional", "Prims.eq2", "FStar.Ghost.reveal", "LowStar.RVector.rvector", "LowStar.Vector.free", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia) val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0 let buffer_r_alloc_p #a v = True /// This is the key example here that illustrates how to efficiently do /// closure-conversion by hand: we have at run-time a function that takes /// ``arg`` (an actual parameter) that contains the closure state. However, if /// the function only takes ``arg``, it will have a type that is too /// polymorphic, i.e. it'll have type ``forall arg. arg -> ...``. Therefore, we /// add ``arg'`` which is an erased, type-only index which, once instantiated, /// restricts the domain of the function to operate on the sole value being /// captured. val buffer_r_alloc: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> r:HST.erid -> HST.ST (B.buffer a) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> let ia = fst arg in let len = snd arg in Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (B.loc_buffer v) h0 h1 /\ buffer_r_alloc_p v /\ buffer_r_inv len h1 v /\ buffer_region_of v = r /\ buffer_r_repr len h1 v == Ghost.reveal (buffer_irepr ia len))) let buffer_r_alloc #a #_ (ia, len) r = B.malloc r ia len val buffer_r_free: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero) { arg == Ghost.reveal arg' } -> v:B.buffer a -> HST.ST unit (requires (fun h0 -> let ia = fst arg in let len = snd arg in buffer_r_inv len h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (buffer_region_of v)) h0 h1)) let buffer_r_free #a len v = B.free v val buffer_copy: #a:Type -> #arg':Ghost.erased (a & nonzero) -> arg:(a & nonzero){ arg == Ghost.reveal arg' } -> src:B.buffer a -> dst:B.buffer a -> HST.ST unit (requires (fun h0 -> let len = snd arg in buffer_r_inv len h0 src /\ buffer_r_inv len h0 dst /\ HS.disjoint (buffer_region_of src) (buffer_region_of dst))) (ensures (fun h0 _ h1 -> let len = snd arg in modifies (loc_all_regions_from false (buffer_region_of dst)) h0 h1 /\ buffer_r_inv len h1 dst /\ buffer_r_repr len h1 dst == buffer_r_repr len h0 src)) let buffer_copy #a #_ (ia, len) src dst = B.blit src 0ul dst 0ul len #set-options "--print_implicits" val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a) let buffer_regional #a ia len = Rgl (ia, len) (buffer_region_of #a) B.loc_buffer (buffer_dummy a) (buffer_r_inv #a len) (buffer_r_inv_reg #a len) (buffer_repr a (UInt32.v len)) (buffer_r_repr #a len) (buffer_r_sep #a len) (buffer_irepr #a ia len) (buffer_r_alloc_p #a) // This is key: there is no partial application here, meaning this extracts to C. (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len)) val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional ia len) let buffer_copyable #a ia len = Cpy (buffer_copy #_ #(ia, len)) /// If `a` is regional, then `vector a` is also regional. /// /// We keep a pointer at run-time to the parent type-class. val vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid let vector_region_of #a #rst rg v = V.frameOf v val vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg) let vector_dummy #a #_ _ = V.alloc_empty a val vector_r_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> GTot Type0 let vector_r_inv #a #rst rg h v = RV.rv_inv h v val vector_r_inv_reg: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> Lemma (requires (vector_r_inv rg h v)) (ensures (HS.live_region h (vector_region_of rg v))) let vector_r_inv_reg #a #rst rg h v = () val vector_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Tot Type0 let vector_repr #a #rst rg = S.seq (Rgl?.repr rg) val vector_r_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg{vector_r_inv rg h v} -> GTot (vector_repr rg) let vector_r_repr #a #rst rg h v = RV.as_seq h v val vector_r_sep: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (vector_r_inv rg h0 v /\ loc_disjoint (loc_all_regions_from false (vector_region_of rg v)) p /\ modifies p h0 h1)) (ensures (vector_r_inv rg h1 v /\ vector_r_repr rg h0 v == vector_r_repr rg h1 v)) let vector_r_sep #a #rst rg v p h0 h1 = RV.rv_inv_preserved v p h0 h1; RV.as_seq_preserved v p h0 h1 val vector_irepr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Ghost.erased (vector_repr rg) let vector_irepr #a #rst rg = Ghost.hide S.empty val vector_r_alloc_p: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot Type0 let vector_r_alloc_p #a #rst rg v = V.size_of v = 0ul val vector_r_alloc: #a:Type0 -> #rst:Type -> rg:regional rst a -> r:HST.erid -> HST.ST (rvector rg) (requires (fun h0 -> true)) (ensures (fun h0 v h1 -> Set.subset (Map.domain (HS.get_hmap h0)) (Map.domain (HS.get_hmap h1)) /\ modifies loc_none h0 h1 /\ fresh_loc (V.loc_vector v) h0 h1 /\ vector_r_alloc_p rg v /\ vector_r_inv rg h1 v /\ vector_region_of rg v = r /\ vector_r_repr rg h1 v == Ghost.reveal (vector_irepr rg))) let vector_r_alloc #a #rst rg r = let nrid = HST.new_region r in V.alloc_reserve 1ul (rg_dummy rg) r val vector_r_free: #a:Type0 -> #rst:Type -> #rg:Ghost.erased (regional rst a) -> (s:regional rst a{s == Ghost.reveal rg}) -> v:rvector rg -> HST.ST unit (requires (fun h0 -> vector_r_inv rg h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (vector_region_of rg v)) h0 h1))
false
false
LowStar.Regional.Instances.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 vector_r_free: #a:Type0 -> #rst:Type -> #rg:Ghost.erased (regional rst a) -> (s:regional rst a{s == Ghost.reveal rg}) -> v:rvector rg -> HST.ST unit (requires (fun h0 -> vector_r_inv rg h0 v)) (ensures (fun h0 _ h1 -> modifies (loc_all_regions_from false (vector_region_of rg v)) h0 h1))
[]
LowStar.Regional.Instances.vector_r_free
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: LowStar.Regional.regional rst a {s == FStar.Ghost.reveal rg} -> v: LowStar.RVector.rvector (FStar.Ghost.reveal rg) -> FStar.HyperStack.ST.ST Prims.unit
{ "end_col": 10, "end_line": 260, "start_col": 2, "start_line": 260 }
Prims.Tot
val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len))
[ { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": 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 buffer_irepr #a ia len = Ghost.hide (S.create (UInt32.v len) ia)
val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len)) let buffer_irepr #a ia len =
false
null
false
Ghost.hide (S.create (UInt32.v len) ia)
{ "checked_file": "LowStar.Regional.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Regional.Instances.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.b2t", "FStar.Integers.op_Greater", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.UInt32.__uint_to_t", "FStar.Ghost.hide", "LowStar.Regional.Instances.buffer_repr", "FStar.UInt32.v", "FStar.Seq.Base.create", "FStar.Ghost.erased" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.Regional.Instances open FStar.Integers open LowStar.Buffer open LowStar.Regional open LowStar.RVector module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module S = FStar.Seq module B = LowStar.Buffer module V = LowStar.Vector module RV = LowStar.RVector /// `LowStar.Buffer` is regional val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid let buffer_region_of #a v = B.frameOf v val buffer_dummy: a:Type -> Tot (B.buffer a) let buffer_dummy _ = B.null let nonzero = len:UInt32.t{len > 0ul} val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0 let buffer_r_inv #a len h v = B.live h v /\ B.freeable v /\ B.len v == len val buffer_r_inv_reg: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> Lemma (requires (buffer_r_inv len h v)) (ensures (HS.live_region h (buffer_region_of v))) let buffer_r_inv_reg #a len h v = () val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0 let buffer_repr a len = s:S.seq a{S.length s = len} val buffer_r_repr: #a:Type -> len:UInt32.t{len > 0ul} -> h:HS.mem -> v:B.buffer a{buffer_r_inv len h v} -> GTot (buffer_repr a (UInt32.v len)) let buffer_r_repr #a len h v = B.as_seq h v val buffer_r_sep: #a:Type -> len:UInt32.t{len > 0ul} -> v:B.buffer a -> p:loc -> h0:HS.mem -> h1:HS.mem -> Lemma (requires (buffer_r_inv len h0 v /\ loc_disjoint (loc_all_regions_from false (buffer_region_of v)) p /\ modifies p h0 h1)) (ensures (buffer_r_inv len h1 v /\ buffer_r_repr len h0 v == buffer_r_repr len h1 v)) let buffer_r_sep #a len v p h0 h1 = assert (loc_includes (loc_all_regions_from false (buffer_region_of v)) (loc_buffer v)); B.modifies_buffer_elim v p h0 h1 val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len))
false
false
LowStar.Regional.Instances.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 buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len))
[]
LowStar.Regional.Instances.buffer_irepr
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
ia: a -> len: FStar.UInt32.t{len > 0ul} -> FStar.Ghost.erased (LowStar.Regional.Instances.buffer_repr a (FStar.UInt32.v len))
{ "end_col": 41, "end_line": 85, "start_col": 2, "start_line": 85 }