file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.load_blocks_spec4_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)
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) = LSeq.eq_intro (SpecVec.load_blocks b) (load_blocks_spec4 b)
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 61, "end_line": 159, "start_col": 0, "start_line": 156 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
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)
false
FStar.FunctionalExtensionality.fst
FStar.FunctionalExtensionality.l_to_r
val l_to_r (t: term) : Tac unit
val l_to_r (t: term) : Tac unit
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)
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 53, "start_col": 0, "start_line": 48 }
(* 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.Stubs.Tactics.V2.Builtins open FStar.Stubs.Reflection.Types open FStar.Stubs.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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.fsti.checked", "FStar.Stubs.Tactics.Types.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Tactics.V2.Builtins.ctrl_rewrite", "FStar.Stubs.Tactics.Types.BottomUp", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "FStar.Stubs.Tactics.Types.ctrl_flag", "FStar.Stubs.Tactics.Types.Continue", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.FunctionalExtensionality.try_with", "FStar.Stubs.Tactics.V2.Builtins.t_apply_lemma", "Prims.exn", "FStar.Stubs.Tactics.V2.Builtins.t_trefl" ]
[]
false
true
false
false
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)
false
FStar.FunctionalExtensionality.fst
FStar.FunctionalExtensionality.on_domain_g
val on_domain_g (a: Type) (#b: (a -> Type)) (f: arrow_g a b) : Tot (arrow_g a b)
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) = fun (x:a) -> f x
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 78, "start_col": 0, "start_line": 77 }
(* 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.Stubs.Tactics.V2.Builtins open FStar.Stubs.Reflection.Types open FStar.Stubs.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 ******)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.fsti.checked", "FStar.Stubs.Tactics.Types.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> f: FStar.FunctionalExtensionality.arrow_g a b -> FStar.FunctionalExtensionality.arrow_g a b
Prims.Tot
[ "total" ]
[]
[ "FStar.FunctionalExtensionality.arrow_g" ]
[]
false
false
false
false
false
let on_domain_g (a: Type) (#b: (a -> Type)) (f: arrow_g a b) =
fun (x: a) -> f x
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.padded_blocks
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)}
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)} = if (len +! len_len a +! 1ul <=. HD.block_len a) then 1ul else 2ul
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 67, "end_line": 357, "start_col": 0, "start_line": 354 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)}
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
FStar.FunctionalExtensionality.fst
FStar.FunctionalExtensionality.idempotence_on_domain
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))]
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 = assert_norm (on_domain a f == (on_domain a (on_domain a f)))
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 27, "start_col": 0, "start_line": 26 }
(* 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) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.fsti.checked", "FStar.Stubs.Tactics.Types.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: 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)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.FunctionalExtensionality.arrow", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.FunctionalExtensionality.on_domain", "Prims.unit" ]
[]
true
false
true
false
false
let idempotence_on_domain #a #b f =
assert_norm (on_domain a f == (on_domain a (on_domain a f)))
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.load_blocks
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))
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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 294, "start_col": 0, "start_line": 290 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
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
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.transpose_state
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))
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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 582, "start_col": 0, "start_line": 578 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
st: Hacl.Impl.SHA2.Core.state_t a m -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
false
let transpose_state #a #m st =
match lanes a m with | 1 -> () | 4 -> transpose_state4 st | 8 -> transpose_state8 st
false
FStar.Tactics.Visit.fst
FStar.Tactics.Visit.visit_br
val visit_br (ff: (term -> Tac term)) (b: branch) : Tac branch
val visit_br (ff: (term -> Tac term)) (b: branch) : Tac branch
let rec visit_tm (ff : term -> Tac term) (t : term) : Tac term = let tv = inspect_ln t in let tv' = match tv with | Tv_FVar _ | Tv_Var _ | Tv_BVar _ | Tv_UInst _ _ -> tv | Tv_Type u -> Tv_Type u | Tv_Const c -> Tv_Const c | Tv_Uvar i u -> Tv_Uvar i u | Tv_Unknown -> Tv_Unknown | Tv_Unsupp -> Tv_Unsupp | Tv_Arrow b c -> let b = on_sort_binder (visit_tm ff) b in let c = visit_comp ff c in Tv_Arrow b c | Tv_Abs b t -> let b = on_sort_binder (visit_tm ff) b in let t = visit_tm ff t in Tv_Abs b t | Tv_App l (r, q) -> let l = visit_tm ff l in let r = visit_tm ff r in Tv_App l (r, q) | Tv_Refine b r -> let b = on_sort_simple_binder (visit_tm ff) b in let r = visit_tm ff r in Tv_Refine b r | Tv_Let r attrs b def t -> let b = on_sort_simple_binder (visit_tm ff) b in let def = visit_tm ff def in let t = visit_tm ff t in Tv_Let r attrs b def t | Tv_Match sc ret_opt brs -> let sc = visit_tm ff sc in let ret_opt = map_opt (fun (b, asc) -> let b = on_sort_binder (visit_tm ff) b in let asc = match asc with | Inl t, tacopt, use_eq -> Inl (visit_tm ff t), map_opt (visit_tm ff) tacopt, use_eq | Inr c, tacopt, use_eq-> Inr (visit_comp ff c), map_opt (visit_tm ff) tacopt, use_eq in b, asc) ret_opt in let brs = map (visit_br ff) brs in Tv_Match sc ret_opt brs | Tv_AscribedT e t topt use_eq -> let e = visit_tm ff e in let t = visit_tm ff t in Tv_AscribedT e t topt use_eq | Tv_AscribedC e c topt use_eq -> let e = visit_tm ff e in let c = visit_comp ff c in Tv_AscribedC e c topt use_eq in ff (pack_ln tv') and visit_br (ff : term -> Tac term) (b:branch) : Tac branch = let (p, t) = b in let p = visit_pat ff p in let t = visit_tm ff t in (p, t) and visit_pat (ff : term -> Tac term) (p:pattern) : Tac pattern = match p with | Pat_Constant _ -> p | Pat_Var v s -> Pat_Var v s | Pat_Cons head univs subpats -> let subpats = (map (fun(p,b) -> (visit_pat ff p, b)) subpats) in Pat_Cons head univs subpats | Pat_Dot_Term t -> let t = map_opt (visit_tm ff) t in Pat_Dot_Term t and visit_comp (ff : term -> Tac term) (c : comp) : Tac comp = let cv = inspect_comp c in let cv' = match cv with | C_Total ret -> let ret = visit_tm ff ret in C_Total ret | C_GTotal ret -> let ret = visit_tm ff ret in C_GTotal ret | C_Lemma pre post pats -> let pre = visit_tm ff pre in let post = visit_tm ff post in let pats = visit_tm ff pats in C_Lemma pre post pats | C_Eff us eff res args decrs -> let res = visit_tm ff res in let args = map (fun (a, q) -> (visit_tm ff a, q)) args in let decrs = map (visit_tm ff) decrs in C_Eff us eff res args decrs in pack_comp cv'
{ "file_name": "ulib/FStar.Tactics.Visit.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 134, "start_col": 0, "start_line": 36 }
(* 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.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 (* Same *) 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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Util.fst.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" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ff: (_: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.term) -> b: FStar.Stubs.Reflection.V2.Data.branch -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.V2.Data.branch
FStar.Tactics.Effect.Tac
[]
[ "visit_tm", "visit_br", "visit_pat", "visit_comp" ]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.branch", "FStar.Stubs.Reflection.V2.Data.pattern", "FStar.Pervasives.Native.Mktuple2", "FStar.Tactics.Visit.visit_tm", "FStar.Tactics.Visit.visit_pat" ]
[ "mutual recursion" ]
false
true
false
false
false
let rec visit_br (ff: (term -> Tac term)) (b: branch) : Tac branch =
let p, t = b in let p = visit_pat ff p in let t = visit_tm ff t in (p, t)
false
FStar.FunctionalExtensionality.fst
FStar.FunctionalExtensionality.try_with
val try_with (f: (unit -> Tac 'a)) (h: (exn -> Tac 'a)) : Tac 'a
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 = match catch f with | Inl e -> h e | Inr x -> x
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 45, "start_col": 0, "start_line": 42 }
(* 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.Stubs.Tactics.V2.Builtins open FStar.Stubs.Reflection.Types open FStar.Stubs.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 *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.fsti.checked", "FStar.Stubs.Tactics.Types.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.unit -> FStar.Tactics.Effect.Tac 'a) -> h: (_: Prims.exn -> FStar.Tactics.Effect.Tac 'a) -> FStar.Tactics.Effect.Tac 'a
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "Prims.exn", "FStar.Pervasives.either", "FStar.Stubs.Tactics.V2.Builtins.catch" ]
[]
false
true
false
false
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
false
FStar.FunctionalExtensionality.fst
FStar.FunctionalExtensionality.extensionality_1
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)
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) = 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)
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 26, "end_line": 63, "start_col": 0, "start_line": 55 }
(* 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.Stubs.Tactics.V2.Builtins open FStar.Stubs.Reflection.Types open FStar.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.fsti.checked", "FStar.Stubs.Tactics.Types.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> b: (_: 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)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.FunctionalExtensionality.arrow", "Prims.squash", "FStar.FunctionalExtensionality.feq", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "FStar.FunctionalExtensionality.on_domain", "Prims.unit", "FStar.Stubs.Tactics.V2.Builtins.t_trefl", "FStar.FunctionalExtensionality.l_to_r", "FStar.Stubs.Reflection.Types.term", "FStar.FunctionalExtensionality.quantifier_as_lemma", "FStar.Stubs.Tactics.V2.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "Prims.l_True", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
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) =
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))
false
FStar.Tactics.Visit.fst
FStar.Tactics.Visit.visit_tm
val visit_tm (ff: (term -> Tac term)) (t: term) : Tac term
val visit_tm (ff: (term -> Tac term)) (t: term) : Tac term
let rec visit_tm (ff : term -> Tac term) (t : term) : Tac term = let tv = inspect_ln t in let tv' = match tv with | Tv_FVar _ | Tv_Var _ | Tv_BVar _ | Tv_UInst _ _ -> tv | Tv_Type u -> Tv_Type u | Tv_Const c -> Tv_Const c | Tv_Uvar i u -> Tv_Uvar i u | Tv_Unknown -> Tv_Unknown | Tv_Unsupp -> Tv_Unsupp | Tv_Arrow b c -> let b = on_sort_binder (visit_tm ff) b in let c = visit_comp ff c in Tv_Arrow b c | Tv_Abs b t -> let b = on_sort_binder (visit_tm ff) b in let t = visit_tm ff t in Tv_Abs b t | Tv_App l (r, q) -> let l = visit_tm ff l in let r = visit_tm ff r in Tv_App l (r, q) | Tv_Refine b r -> let b = on_sort_simple_binder (visit_tm ff) b in let r = visit_tm ff r in Tv_Refine b r | Tv_Let r attrs b def t -> let b = on_sort_simple_binder (visit_tm ff) b in let def = visit_tm ff def in let t = visit_tm ff t in Tv_Let r attrs b def t | Tv_Match sc ret_opt brs -> let sc = visit_tm ff sc in let ret_opt = map_opt (fun (b, asc) -> let b = on_sort_binder (visit_tm ff) b in let asc = match asc with | Inl t, tacopt, use_eq -> Inl (visit_tm ff t), map_opt (visit_tm ff) tacopt, use_eq | Inr c, tacopt, use_eq-> Inr (visit_comp ff c), map_opt (visit_tm ff) tacopt, use_eq in b, asc) ret_opt in let brs = map (visit_br ff) brs in Tv_Match sc ret_opt brs | Tv_AscribedT e t topt use_eq -> let e = visit_tm ff e in let t = visit_tm ff t in Tv_AscribedT e t topt use_eq | Tv_AscribedC e c topt use_eq -> let e = visit_tm ff e in let c = visit_comp ff c in Tv_AscribedC e c topt use_eq in ff (pack_ln tv') and visit_br (ff : term -> Tac term) (b:branch) : Tac branch = let (p, t) = b in let p = visit_pat ff p in let t = visit_tm ff t in (p, t) and visit_pat (ff : term -> Tac term) (p:pattern) : Tac pattern = match p with | Pat_Constant _ -> p | Pat_Var v s -> Pat_Var v s | Pat_Cons head univs subpats -> let subpats = (map (fun(p,b) -> (visit_pat ff p, b)) subpats) in Pat_Cons head univs subpats | Pat_Dot_Term t -> let t = map_opt (visit_tm ff) t in Pat_Dot_Term t and visit_comp (ff : term -> Tac term) (c : comp) : Tac comp = let cv = inspect_comp c in let cv' = match cv with | C_Total ret -> let ret = visit_tm ff ret in C_Total ret | C_GTotal ret -> let ret = visit_tm ff ret in C_GTotal ret | C_Lemma pre post pats -> let pre = visit_tm ff pre in let post = visit_tm ff post in let pats = visit_tm ff pats in C_Lemma pre post pats | C_Eff us eff res args decrs -> let res = visit_tm ff res in let args = map (fun (a, q) -> (visit_tm ff a, q)) args in let decrs = map (visit_tm ff) decrs in C_Eff us eff res args decrs in pack_comp cv'
{ "file_name": "ulib/FStar.Tactics.Visit.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 134, "start_col": 0, "start_line": 36 }
(* 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.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 (* Same *) 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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Util.fst.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" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ff: (_: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.term) -> t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.term
FStar.Tactics.Effect.Tac
[]
[ "visit_tm", "visit_br", "visit_pat", "visit_comp" ]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.term_view", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.Types.namedv", "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.V2.Data.Tv_Type", "FStar.Stubs.Reflection.V2.Data.vconst", "FStar.Stubs.Reflection.V2.Data.Tv_Const", "Prims.nat", "FStar.Stubs.Reflection.Types.ctx_uvar_and_subst", "FStar.Stubs.Reflection.V2.Data.Tv_Uvar", "FStar.Stubs.Reflection.V2.Data.Tv_Unknown", "FStar.Stubs.Reflection.V2.Data.Tv_Unsupp", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V2.Data.Tv_Arrow", "FStar.Tactics.Visit.visit_comp", "FStar.Tactics.Visit.on_sort_binder", "FStar.Tactics.Visit.visit_tm", "FStar.Stubs.Reflection.V2.Data.Tv_Abs", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Tv_App", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.simple_binder", "FStar.Stubs.Reflection.V2.Data.Tv_Refine", "FStar.Tactics.Visit.on_sort_simple_binder", "Prims.bool", "Prims.list", "FStar.Stubs.Reflection.V2.Data.Tv_Let", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.match_returns_ascription", "FStar.Stubs.Reflection.V2.Data.branch", "FStar.Stubs.Reflection.V2.Data.Tv_Match", "FStar.Tactics.Util.map", "FStar.Tactics.Visit.visit_br", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.either", "FStar.Tactics.Util.map_opt", "FStar.Pervasives.Native.Mktuple3", "FStar.Pervasives.Inl", "FStar.Pervasives.Inr", "FStar.Stubs.Reflection.V2.Data.Tv_AscribedT", "FStar.Stubs.Reflection.V2.Data.Tv_AscribedC", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln" ]
[ "mutual recursion" ]
false
true
false
false
false
let rec visit_tm (ff: (term -> Tac term)) (t: term) : Tac term =
let tv = inspect_ln t in let tv' = match tv with | Tv_FVar _ | Tv_Var _ | Tv_BVar _ | Tv_UInst _ _ -> tv | Tv_Type u -> Tv_Type u | Tv_Const c -> Tv_Const c | Tv_Uvar i u -> Tv_Uvar i u | Tv_Unknown -> Tv_Unknown | Tv_Unsupp -> Tv_Unsupp | Tv_Arrow b c -> let b = on_sort_binder (visit_tm ff) b in let c = visit_comp ff c in Tv_Arrow b c | Tv_Abs b t -> let b = on_sort_binder (visit_tm ff) b in let t = visit_tm ff t in Tv_Abs b t | Tv_App l (r, q) -> let l = visit_tm ff l in let r = visit_tm ff r in Tv_App l (r, q) | Tv_Refine b r -> let b = on_sort_simple_binder (visit_tm ff) b in let r = visit_tm ff r in Tv_Refine b r | Tv_Let r attrs b def t -> let b = on_sort_simple_binder (visit_tm ff) b in let def = visit_tm ff def in let t = visit_tm ff t in Tv_Let r attrs b def t | Tv_Match sc ret_opt brs -> let sc = visit_tm ff sc in let ret_opt = map_opt (fun (b, asc) -> let b = on_sort_binder (visit_tm ff) b in let asc = match asc with | Inl t, tacopt, use_eq -> Inl (visit_tm ff t), map_opt (visit_tm ff) tacopt, use_eq | Inr c, tacopt, use_eq -> Inr (visit_comp ff c), map_opt (visit_tm ff) tacopt, use_eq in b, asc) ret_opt in let brs = map (visit_br ff) brs in Tv_Match sc ret_opt brs | Tv_AscribedT e t topt use_eq -> let e = visit_tm ff e in let t = visit_tm ff t in Tv_AscribedT e t topt use_eq | Tv_AscribedC e c topt use_eq -> let e = visit_tm ff e in let c = visit_comp ff c in Tv_AscribedC e c topt use_eq in ff (pack_ln tv')
false
FStar.FunctionalExtensionality.fst
FStar.FunctionalExtensionality.extensionality
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)]
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 = 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 ()
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 72, "start_col": 0, "start_line": 65 }
(* 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.Stubs.Tactics.V2.Builtins open FStar.Stubs.Reflection.Types open FStar.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.fsti.checked", "FStar.Stubs.Tactics.Types.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> b: (_: 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)]
FStar.Pervasives.Lemma
[ "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" ]
[]
false
false
true
false
false
let extensionality a b f g =
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 ()
false
FStar.FunctionalExtensionality.fst
FStar.FunctionalExtensionality.idempotence_on_domain_g
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))]
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 = assert_norm (on_domain_g a f == (on_domain_g a (on_domain_g a f)))
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 70, "end_line": 84, "start_col": 0, "start_line": 83 }
(* 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.Stubs.Tactics.V2.Builtins open FStar.Stubs.Reflection.Types open FStar.Stubs.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) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.fsti.checked", "FStar.Stubs.Tactics.Types.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: 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)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.FunctionalExtensionality.arrow_g", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.FunctionalExtensionality.on_domain_g", "Prims.unit" ]
[]
true
false
true
false
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)))
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.transpose_ws8
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))
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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 83, "end_line": 322, "start_col": 0, "start_line": 319 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
ws: Hacl.Impl.SHA2.Core.ws_t a m -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
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
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t
val lemma_len_lt_max_a_fits_size_t: a:sha2_alg -> len:size_t -> Lemma (v len `less_than_max_input_length` a)
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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 60, "end_line": 789, "start_col": 0, "start_line": 786 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.Hash.Definitions.sha2_alg", "Lib.IntTypes.size_t", "FStar.Math.Lemmas.pow2_lt_compat", "Prims.unit" ]
[]
false
false
true
false
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
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.transpose_ws4
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))
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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 83, "end_line": 309, "start_col": 0, "start_line": 304 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
ws: Hacl.Impl.SHA2.Core.ws_t a m -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
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
false
FStar.Tactics.Visit.fst
FStar.Tactics.Visit.visit_pat
val visit_pat (ff: (term -> Tac term)) (p: pattern) : Tac pattern
val visit_pat (ff: (term -> Tac term)) (p: pattern) : Tac pattern
let rec visit_tm (ff : term -> Tac term) (t : term) : Tac term = let tv = inspect_ln t in let tv' = match tv with | Tv_FVar _ | Tv_Var _ | Tv_BVar _ | Tv_UInst _ _ -> tv | Tv_Type u -> Tv_Type u | Tv_Const c -> Tv_Const c | Tv_Uvar i u -> Tv_Uvar i u | Tv_Unknown -> Tv_Unknown | Tv_Unsupp -> Tv_Unsupp | Tv_Arrow b c -> let b = on_sort_binder (visit_tm ff) b in let c = visit_comp ff c in Tv_Arrow b c | Tv_Abs b t -> let b = on_sort_binder (visit_tm ff) b in let t = visit_tm ff t in Tv_Abs b t | Tv_App l (r, q) -> let l = visit_tm ff l in let r = visit_tm ff r in Tv_App l (r, q) | Tv_Refine b r -> let b = on_sort_simple_binder (visit_tm ff) b in let r = visit_tm ff r in Tv_Refine b r | Tv_Let r attrs b def t -> let b = on_sort_simple_binder (visit_tm ff) b in let def = visit_tm ff def in let t = visit_tm ff t in Tv_Let r attrs b def t | Tv_Match sc ret_opt brs -> let sc = visit_tm ff sc in let ret_opt = map_opt (fun (b, asc) -> let b = on_sort_binder (visit_tm ff) b in let asc = match asc with | Inl t, tacopt, use_eq -> Inl (visit_tm ff t), map_opt (visit_tm ff) tacopt, use_eq | Inr c, tacopt, use_eq-> Inr (visit_comp ff c), map_opt (visit_tm ff) tacopt, use_eq in b, asc) ret_opt in let brs = map (visit_br ff) brs in Tv_Match sc ret_opt brs | Tv_AscribedT e t topt use_eq -> let e = visit_tm ff e in let t = visit_tm ff t in Tv_AscribedT e t topt use_eq | Tv_AscribedC e c topt use_eq -> let e = visit_tm ff e in let c = visit_comp ff c in Tv_AscribedC e c topt use_eq in ff (pack_ln tv') and visit_br (ff : term -> Tac term) (b:branch) : Tac branch = let (p, t) = b in let p = visit_pat ff p in let t = visit_tm ff t in (p, t) and visit_pat (ff : term -> Tac term) (p:pattern) : Tac pattern = match p with | Pat_Constant _ -> p | Pat_Var v s -> Pat_Var v s | Pat_Cons head univs subpats -> let subpats = (map (fun(p,b) -> (visit_pat ff p, b)) subpats) in Pat_Cons head univs subpats | Pat_Dot_Term t -> let t = map_opt (visit_tm ff) t in Pat_Dot_Term t and visit_comp (ff : term -> Tac term) (c : comp) : Tac comp = let cv = inspect_comp c in let cv' = match cv with | C_Total ret -> let ret = visit_tm ff ret in C_Total ret | C_GTotal ret -> let ret = visit_tm ff ret in C_GTotal ret | C_Lemma pre post pats -> let pre = visit_tm ff pre in let post = visit_tm ff post in let pats = visit_tm ff pats in C_Lemma pre post pats | C_Eff us eff res args decrs -> let res = visit_tm ff res in let args = map (fun (a, q) -> (visit_tm ff a, q)) args in let decrs = map (visit_tm ff) decrs in C_Eff us eff res args decrs in pack_comp cv'
{ "file_name": "ulib/FStar.Tactics.Visit.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 134, "start_col": 0, "start_line": 36 }
(* 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.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 (* Same *) 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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Util.fst.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" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ff: (_: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.term) -> p: FStar.Stubs.Reflection.V2.Data.pattern -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.V2.Data.pattern
FStar.Tactics.Effect.Tac
[]
[ "visit_tm", "visit_br", "visit_pat", "visit_comp" ]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.pattern", "FStar.Stubs.Reflection.V2.Data.vconst", "FStar.Sealed.sealed", "FStar.Stubs.Reflection.V2.Data.ppname_t", "FStar.Stubs.Reflection.V2.Data.Pat_Var", "FStar.Stubs.Reflection.Types.fv", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.V2.Data.universes", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.bool", "FStar.Stubs.Reflection.V2.Data.Pat_Cons", "FStar.Tactics.Util.map", "FStar.Pervasives.Native.Mktuple2", "FStar.Tactics.Visit.visit_pat", "FStar.Stubs.Reflection.V2.Data.Pat_Dot_Term", "FStar.Tactics.Util.map_opt", "FStar.Tactics.Visit.visit_tm" ]
[ "mutual recursion" ]
false
true
false
false
false
let rec visit_pat (ff: (term -> Tac term)) (p: pattern) : Tac pattern =
match p with | Pat_Constant _ -> p | Pat_Var v s -> Pat_Var v s | Pat_Cons head univs subpats -> let subpats = (map (fun (p, b) -> (visit_pat ff p, b)) subpats) in Pat_Cons head univs subpats | Pat_Dot_Term t -> let t = map_opt (visit_tm ff) t in Pat_Dot_Term t
false
FStar.FunctionalExtensionality.fst
FStar.FunctionalExtensionality.extensionality_g
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)]
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 = 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 ()
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 103, "start_col": 0, "start_line": 96 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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.Stubs.Tactics.V2.Builtins open FStar.Stubs.Reflection.Types open FStar.Stubs.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)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.fsti.checked", "FStar.Stubs.Tactics.Types.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> b: (_: 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)]
FStar.Pervasives.Lemma
[ "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" ]
[]
false
false
true
false
false
let extensionality_g a b f g =
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 ()
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.transpose_state4
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))
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'
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 556, "start_col": 0, "start_line": 553 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
st: Hacl.Impl.SHA2.Core.state_t a m -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
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'
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.load_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))
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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 17, "end_line": 350, "start_col": 0, "start_line": 348 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
false
let load_ws #a #m b ws =
load_blocks b ws; transpose_ws ws
false
FStar.Tactics.Visit.fst
FStar.Tactics.Visit.visit_comp
val visit_comp (ff: (term -> Tac term)) (c: comp) : Tac comp
val visit_comp (ff: (term -> Tac term)) (c: comp) : Tac comp
let rec visit_tm (ff : term -> Tac term) (t : term) : Tac term = let tv = inspect_ln t in let tv' = match tv with | Tv_FVar _ | Tv_Var _ | Tv_BVar _ | Tv_UInst _ _ -> tv | Tv_Type u -> Tv_Type u | Tv_Const c -> Tv_Const c | Tv_Uvar i u -> Tv_Uvar i u | Tv_Unknown -> Tv_Unknown | Tv_Unsupp -> Tv_Unsupp | Tv_Arrow b c -> let b = on_sort_binder (visit_tm ff) b in let c = visit_comp ff c in Tv_Arrow b c | Tv_Abs b t -> let b = on_sort_binder (visit_tm ff) b in let t = visit_tm ff t in Tv_Abs b t | Tv_App l (r, q) -> let l = visit_tm ff l in let r = visit_tm ff r in Tv_App l (r, q) | Tv_Refine b r -> let b = on_sort_simple_binder (visit_tm ff) b in let r = visit_tm ff r in Tv_Refine b r | Tv_Let r attrs b def t -> let b = on_sort_simple_binder (visit_tm ff) b in let def = visit_tm ff def in let t = visit_tm ff t in Tv_Let r attrs b def t | Tv_Match sc ret_opt brs -> let sc = visit_tm ff sc in let ret_opt = map_opt (fun (b, asc) -> let b = on_sort_binder (visit_tm ff) b in let asc = match asc with | Inl t, tacopt, use_eq -> Inl (visit_tm ff t), map_opt (visit_tm ff) tacopt, use_eq | Inr c, tacopt, use_eq-> Inr (visit_comp ff c), map_opt (visit_tm ff) tacopt, use_eq in b, asc) ret_opt in let brs = map (visit_br ff) brs in Tv_Match sc ret_opt brs | Tv_AscribedT e t topt use_eq -> let e = visit_tm ff e in let t = visit_tm ff t in Tv_AscribedT e t topt use_eq | Tv_AscribedC e c topt use_eq -> let e = visit_tm ff e in let c = visit_comp ff c in Tv_AscribedC e c topt use_eq in ff (pack_ln tv') and visit_br (ff : term -> Tac term) (b:branch) : Tac branch = let (p, t) = b in let p = visit_pat ff p in let t = visit_tm ff t in (p, t) and visit_pat (ff : term -> Tac term) (p:pattern) : Tac pattern = match p with | Pat_Constant _ -> p | Pat_Var v s -> Pat_Var v s | Pat_Cons head univs subpats -> let subpats = (map (fun(p,b) -> (visit_pat ff p, b)) subpats) in Pat_Cons head univs subpats | Pat_Dot_Term t -> let t = map_opt (visit_tm ff) t in Pat_Dot_Term t and visit_comp (ff : term -> Tac term) (c : comp) : Tac comp = let cv = inspect_comp c in let cv' = match cv with | C_Total ret -> let ret = visit_tm ff ret in C_Total ret | C_GTotal ret -> let ret = visit_tm ff ret in C_GTotal ret | C_Lemma pre post pats -> let pre = visit_tm ff pre in let post = visit_tm ff post in let pats = visit_tm ff pats in C_Lemma pre post pats | C_Eff us eff res args decrs -> let res = visit_tm ff res in let args = map (fun (a, q) -> (visit_tm ff a, q)) args in let decrs = map (visit_tm ff) decrs in C_Eff us eff res args decrs in pack_comp cv'
{ "file_name": "ulib/FStar.Tactics.Visit.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 134, "start_col": 0, "start_line": 36 }
(* 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.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 (* Same *) 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
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Util.fst.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" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Util", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ff: (_: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.term) -> c: FStar.Stubs.Reflection.Types.comp -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.comp
FStar.Tactics.Effect.Tac
[]
[ "visit_tm", "visit_br", "visit_pat", "visit_comp" ]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V2.Builtins.pack_comp", "FStar.Stubs.Reflection.V2.Data.comp_view", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.V2.Data.C_Total", "FStar.Tactics.Visit.visit_tm", "FStar.Stubs.Reflection.V2.Data.C_GTotal", "FStar.Stubs.Reflection.V2.Data.C_Lemma", "FStar.Stubs.Reflection.V2.Data.universes", "FStar.Stubs.Reflection.Types.name", "Prims.list", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Stubs.Reflection.V2.Data.C_Eff", "FStar.Tactics.Util.map", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Pervasives.Native.Mktuple2", "Prims.precedes", "FStar.Stubs.Reflection.V2.Builtins.inspect_comp" ]
[ "mutual recursion" ]
false
true
false
false
false
let rec visit_comp (ff: (term -> Tac term)) (c: comp) : Tac comp =
let cv = inspect_comp c in let cv' = match cv with | C_Total ret -> let ret = visit_tm ff ret in C_Total ret | C_GTotal ret -> let ret = visit_tm ff ret in C_GTotal ret | C_Lemma pre post pats -> let pre = visit_tm ff pre in let post = visit_tm ff post in let pats = visit_tm ff pats in C_Lemma pre post pats | C_Eff us eff res args decrs -> let res = visit_tm ff res in let args = map (fun (a, q) -> (visit_tm ff a, q)) args in let decrs = map (visit_tm ff) decrs in C_Eff us eff res args decrs in pack_comp cv'
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.transpose_state8
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))
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'
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 568, "start_col": 0, "start_line": 566 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
st: Hacl.Impl.SHA2.Core.state_t a m -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
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'
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.load_last
val load_last: #a:sha2_alg -> #m:m_spec{is_supported a m} -> load_last_t a m
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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 543, "start_col": 0, "start_line": 539 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Hacl.Impl.SHA2.Core.load_last_t a m
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
FStar.FunctionalExtensionality.fst
FStar.FunctionalExtensionality.extensionality_1_g
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)
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) = 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)
{ "file_name": "ulib/FStar.FunctionalExtensionality.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 26, "end_line": 94, "start_col": 0, "start_line": 86 }
(* 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.Stubs.Tactics.V2.Builtins open FStar.Stubs.Reflection.Types open FStar.Stubs.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)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V2.Builtins.fsti.checked", "FStar.Stubs.Tactics.Types.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "FStar.FunctionalExtensionality.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> b: (_: 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)
FStar.Pervasives.Lemma
[ "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.Stubs.Tactics.V2.Builtins.t_trefl", "FStar.FunctionalExtensionality.l_to_r", "FStar.Stubs.Reflection.Types.term", "FStar.FunctionalExtensionality.quantifier_as_lemma", "FStar.Stubs.Tactics.V2.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_only", "Prims.string", "Prims.Nil", "Prims.l_True", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
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) =
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))
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.get_multiblock_t
val get_multiblock_t : a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
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)))
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 88, "end_line": 801, "start_col": 0, "start_line": 793 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
Prims.Tot
[ "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" ]
[]
false
false
false
true
true
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)))
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.emit1_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)
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) = Lib.NTuple.eq_intro (emit1_spec #a #m hseq) (SpecVec.emit #a #m hseq)
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 612, "start_col": 0, "start_line": 609 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
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)
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.emit1_spec
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)
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) = let hsub = LSeq.sub hseq 0 (hash_length a) in ntup1 hsub
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 12, "end_line": 605, "start_col": 0, "start_line": 601 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_region_of
val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid
val buffer_region_of: #a:Type -> v:B.buffer a -> GTot HS.rid
let buffer_region_of #a v = B.frameOf v
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 36, "start_col": 0, "start_line": 35 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module 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:
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v: LowStar.Buffer.buffer a -> Prims.GTot FStar.Monotonic.HyperHeap.rid
Prims.GTot
[ "sometrivial" ]
[]
[ "LowStar.Buffer.buffer", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Buffer.trivial_preorder", "FStar.Monotonic.HyperHeap.rid" ]
[]
false
false
false
false
false
let buffer_region_of #a v =
B.frameOf v
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_dummy
val buffer_dummy: a:Type -> Tot (B.buffer a)
val buffer_dummy: a:Type -> Tot (B.buffer a)
let buffer_dummy _ = B.null
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 39, "start_col": 0, "start_line": 39 }
(* 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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type0 -> LowStar.Buffer.buffer a
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.null", "LowStar.Buffer.buffer" ]
[]
false
false
false
true
false
let buffer_dummy _ =
B.null
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.emit4_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)
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) = Lib.NTuple.eq_intro (emit4_spec #a #m hseq) (SpecVec.emit #a #m hseq)
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 651, "start_col": 0, "start_line": 648 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
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)
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.nonzero
val nonzero : Type0
let nonzero = len:UInt32.t{len > 0ul}
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 41, "start_col": 0, "start_line": 41 }
(* 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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "Prims.b2t", "FStar.Integers.op_Greater", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
true
true
let nonzero =
len: UInt32.t{len > 0ul}
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.b128
val b128 : Type0
let b128 = buf_t TUInt8 TUInt128
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 37, "start_col": 0, "start_line": 37 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.buf_t", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128" ]
[]
false
false
false
true
true
let b128 =
buf_t TUInt8 TUInt128
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.load_last_t
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
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))
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 87, "end_line": 411, "start_col": 0, "start_line": 396 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec{Hacl.Spec.SHA2.Vec.is_supported a m} -> Type0
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
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))
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.uint64
val uint64 : Prims.eqtype
let uint64 = UInt64.t
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 28, "start_col": 0, "start_line": 28 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t" ]
[]
false
false
false
true
false
let uint64 =
UInt64.t
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.t128_mod
val t128_mod : Vale.Interop.Base.td
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 39, "start_col": 0, "start_line": 39 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.TD_Buffer", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.Interop.Base.default_bq" ]
[]
false
false
false
true
false
let t128_mod =
TD_Buffer TUInt8 TUInt128 default_bq
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.tuint64
val tuint64 : Vale.Interop.Base.td
let tuint64 = TD_Base TUInt64
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 45, "start_col": 0, "start_line": 45 }
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})
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
false
false
true
false
let tuint64 =
TD_Base TUInt64
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.t128_mod_pub
val t128_mod_pub : Vale.Interop.Base.td
let t128_mod_pub = TD_Buffer TUInt8 TUInt128 ({modified=true; strict_disjointness=false; taint=MS.Public})
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 106, "end_line": 41, "start_col": 0, "start_line": 41 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.td
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let t128_mod_pub =
TD_Buffer TUInt8 TUInt128 ({ modified = true; strict_disjointness = false; taint = MS.Public })
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_r_inv
val buffer_r_inv: #a:Type -> len:nonzero -> h:HS.mem -> v:B.buffer a -> GTot Type0
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 48, "start_col": 0, "start_line": 46 }
(* 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 ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: LowStar.Regional.Instances.nonzero -> h: FStar.Monotonic.HyperStack.mem -> v: LowStar.Buffer.buffer a -> Prims.GTot Type0
Prims.GTot
[ "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" ]
[]
false
false
false
false
true
let buffer_r_inv #a len h v =
B.live h v /\ B.freeable v /\ B.len v == len
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.t128_no_mod
val t128_no_mod : Vale.Interop.Base.td
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 106, "end_line": 43, "start_col": 0, "start_line": 43 }
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})
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.td
Prims.Tot
[ "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" ]
[]
false
false
false
true
false
let t128_no_mod =
TD_Buffer TUInt8 TUInt128 ({ modified = false; strict_disjointness = false; taint = MS.Secret })
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.load_last1
val load_last1: #a:sha2_alg -> #m:m_spec{lanes a m = 1} -> load_last_t a m
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 = 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)
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 432, "start_col": 0, "start_line": 418 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Hacl.Impl.SHA2.Core.load_last_t a m
Prims.Tot
[ "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" ]
[]
false
false
false
false
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)
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.emit8_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)
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) = Lib.NTuple.eq_intro (emit8_spec #a #m hseq) (SpecVec.emit #a #m hseq)
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 71, "end_line": 714, "start_col": 0, "start_line": 711 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
FStar.Pervasives.Lemma
[ "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" ]
[]
true
false
true
false
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)
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_r_alloc_p
val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0
val buffer_r_alloc_p: #a:Type0 -> v:B.buffer a -> GTot Type0
let buffer_r_alloc_p #a v = True
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 90, "start_col": 0, "start_line": 89 }
(* 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:
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v: LowStar.Buffer.buffer a -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "LowStar.Buffer.buffer", "Prims.l_True" ]
[]
false
false
false
false
true
let buffer_r_alloc_p #a v =
True
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.code_gcm128
val code_gcm128 : Vale.X64.Decls.va_code
let code_gcm128 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 70, "end_line": 203, "start_col": 0, "start_line": 203 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall", "Vale.Interop.Assumptions.win", "Vale.AES.AES_common_s.AES_128" ]
[]
false
false
false
true
false
let code_gcm128 =
GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_128
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_region_of
val vector_region_of: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot HS.rid
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 185, "start_col": 0, "start_line": 185 }
(* 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:
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rg: LowStar.Regional.regional rst a -> v: LowStar.RVector.rvector rg -> Prims.GTot FStar.Monotonic.HyperHeap.rid
Prims.GTot
[ "sometrivial" ]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "LowStar.Vector.frameOf", "FStar.Monotonic.HyperHeap.rid" ]
[]
false
false
false
false
false
let vector_region_of #a #rst rg v =
V.frameOf v
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_dummy
val vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg)
val vector_dummy: #a:Type0 -> #rst:Type -> rg:Ghost.erased (regional rst a) -> Tot (rvector rg)
let vector_dummy #a #_ _ = V.alloc_empty a
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 189, "start_col": 0, "start_line": 189 }
(* 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:
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rg: FStar.Ghost.erased (LowStar.Regional.regional rst a) -> LowStar.RVector.rvector (FStar.Ghost.reveal rg)
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.erased", "LowStar.Regional.regional", "LowStar.Vector.alloc_empty", "LowStar.RVector.rvector", "FStar.Ghost.reveal" ]
[]
false
false
false
false
false
let vector_dummy #a #_ _ =
V.alloc_empty a
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_r_inv
val vector_r_inv: #a:Type0 -> #rst:Type -> rg:regional rst a -> h:HS.mem -> v:rvector rg -> GTot Type0
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 194, "start_col": 0, "start_line": 194 }
(* 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 ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rg: LowStar.Regional.regional rst a -> h: FStar.Monotonic.HyperStack.mem -> v: LowStar.RVector.rvector rg -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "LowStar.Regional.regional", "FStar.Monotonic.HyperStack.mem", "LowStar.RVector.rvector", "LowStar.RVector.rv_inv" ]
[]
false
false
false
false
true
let vector_r_inv #a #rst rg h v =
RV.rv_inv h v
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.code_gcm256
val code_gcm256 : Vale.X64.Decls.va_code
let code_gcm256 = GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_256
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 70, "end_line": 375, "start_col": 0, "start_line": 375 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall", "Vale.Interop.Assumptions.win", "Vale.AES.AES_common_s.AES_256" ]
[]
false
false
false
true
false
let code_gcm256 =
GC.va_code_Gcm_blocks_decrypt_stdcall IA.win AES_256
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_repr
val vector_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Tot Type0
val vector_repr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Tot Type0
let vector_repr #a #rst rg = S.seq (Rgl?.repr rg)
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 204, "start_col": 0, "start_line": 204 }
(* 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 = ()
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rg: LowStar.Regional.regional rst a -> Type0
Prims.Tot
[ "total" ]
[]
[ "LowStar.Regional.regional", "FStar.Seq.Base.seq", "LowStar.Regional.__proj__Rgl__item__repr" ]
[]
false
false
false
true
true
let vector_repr #a #rst rg =
S.seq (Rgl?.repr rg)
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_repr
val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0
val buffer_repr: a:Type0 -> len:nat{len > 0} -> Type0
let buffer_repr a len = s:S.seq a{S.length s = len}
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 58, "start_col": 0, "start_line": 58 }
(* 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 = ()
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type0 -> len: FStar.Integers.nat{len > 0} -> Type0
Prims.Tot
[ "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" ]
[]
false
false
false
false
true
let buffer_repr a len =
s: S.seq a {S.length s = len}
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_irepr
val vector_irepr: #a:Type0 -> #rst:Type -> rg:regional rst a -> Ghost.erased (vector_repr rg)
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 229, "start_col": 0, "start_line": 228 }
(* 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:
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rg: LowStar.Regional.regional rst a -> FStar.Ghost.erased (LowStar.Regional.Instances.vector_repr rg)
Prims.Tot
[ "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" ]
[]
false
false
false
false
false
let vector_irepr #a #rst rg =
Ghost.hide S.empty
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_r_repr
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))
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 64, "start_col": 0, "start_line": 64 }
(* 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} ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: FStar.UInt32.t{len > 0ul} -> h: FStar.Monotonic.HyperStack.mem -> v: LowStar.Buffer.buffer a {LowStar.Regional.Instances.buffer_r_inv len h v} -> Prims.GTot (LowStar.Regional.Instances.buffer_repr a (FStar.UInt32.v len))
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.UInt32.t", "Prims.b2t", "FStar.Integers.op_Greater", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.UInt32.__uint_to_t", "FStar.Monotonic.HyperStack.mem", "LowStar.Buffer.buffer", "LowStar.Regional.Instances.buffer_r_inv", "LowStar.Monotonic.Buffer.as_seq", "LowStar.Buffer.trivial_preorder", "LowStar.Regional.Instances.buffer_repr", "FStar.UInt32.v" ]
[]
false
false
false
false
false
let buffer_r_repr #a len h v =
B.as_seq h v
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_r_alloc_p
val vector_r_alloc_p: #a:Type0 -> #rst:Type -> rg:regional rst a -> v:rvector rg -> GTot Type0
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 234, "start_col": 0, "start_line": 233 }
(* 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:
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rg: LowStar.Regional.regional rst a -> v: LowStar.RVector.rvector rg -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "Prims.b2t", "Prims.op_Equality", "FStar.UInt32.t", "LowStar.Vector.size_of", "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
false
true
let vector_r_alloc_p #a #rst rg v =
V.size_of v = 0ul
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_irepr
val buffer_irepr: #a:Type0 -> ia:a -> len:UInt32.t{len > 0ul} -> Ghost.erased (buffer_repr a (UInt32.v len))
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)
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 41, "end_line": 85, "start_col": 0, "start_line": 84 }
(* 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} ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ia: a -> len: FStar.UInt32.t{len > 0ul} -> FStar.Ghost.erased (LowStar.Regional.Instances.buffer_repr a (FStar.UInt32.v len))
Prims.Tot
[ "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" ]
[]
false
false
false
false
false
let buffer_irepr #a ia len =
Ghost.hide (S.create (UInt32.v len) ia)
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.emit
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))
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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 776, "start_col": 0, "start_line": 772 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
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
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_r_sep
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))
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 79, "start_col": 0, "start_line": 76 }
(* 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 /\
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: FStar.UInt32.t{len > 0ul} -> v: LowStar.Buffer.buffer a -> p: LowStar.Monotonic.Buffer.loc -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires LowStar.Regional.Instances.buffer_r_inv len h0 v /\ LowStar.Monotonic.Buffer.loc_disjoint (LowStar.Monotonic.Buffer.loc_all_regions_from false (LowStar.Regional.Instances.buffer_region_of v)) p /\ LowStar.Monotonic.Buffer.modifies p h0 h1) (ensures LowStar.Regional.Instances.buffer_r_inv len h1 v /\ LowStar.Regional.Instances.buffer_r_repr len h0 v == LowStar.Regional.Instances.buffer_r_repr len h1 v)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.UInt32.t", "Prims.b2t", "FStar.Integers.op_Greater", "FStar.Integers.Unsigned", "FStar.Integers.W32", "FStar.UInt32.__uint_to_t", "LowStar.Buffer.buffer", "LowStar.Monotonic.Buffer.loc", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.modifies_buffer_elim", "LowStar.Buffer.trivial_preorder", "Prims.unit", "Prims._assert", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.loc_all_regions_from", "LowStar.Regional.Instances.buffer_region_of", "LowStar.Monotonic.Buffer.loc_buffer" ]
[]
true
false
true
false
false
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
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.emit1
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))
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)
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 631, "start_col": 0, "start_line": 625 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
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)
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_r_alloc
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)))
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 116, "start_col": 0, "start_line": 115 }
(* 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 /\
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
arg: (a * LowStar.Regional.Instances.nonzero) {arg == FStar.Ghost.reveal arg'} -> r: FStar.HyperStack.ST.erid -> FStar.HyperStack.ST.ST (LowStar.Buffer.buffer a)
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Ghost.erased", "FStar.Pervasives.Native.tuple2", "LowStar.Regional.Instances.nonzero", "Prims.eq2", "FStar.Ghost.reveal", "FStar.HyperStack.ST.erid", "LowStar.Buffer.malloc", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.freeable", "LowStar.Buffer.buffer" ]
[]
false
true
false
false
false
let buffer_r_alloc #a #_ (ia, len) r =
B.malloc r ia len
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.emit4_spec
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)
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) = 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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 644, "start_col": 0, "start_line": 635 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_r_free
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))
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 131, "start_col": 0, "start_line": 130 }
(* 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 ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
arg: (a * LowStar.Regional.Instances.nonzero) {arg == FStar.Ghost.reveal arg'} -> v: LowStar.Buffer.buffer a -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "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" ]
[]
false
true
false
false
false
let buffer_r_free #a len v =
B.free v
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.load_last_blocks
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)))
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 = 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)
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 386, "start_col": 0, "start_line": 377 }
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)))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
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))
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
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)
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_regional
val buffer_regional: #a:Type -> ia:a -> len:nonzero -> regional (a & nonzero) (B.buffer a)
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))
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 169, "start_col": 0, "start_line": 155 }
(* 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 ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ia: a -> len: LowStar.Regional.Instances.nonzero -> LowStar.Regional.regional (a * LowStar.Regional.Instances.nonzero) (LowStar.Buffer.buffer a)
Prims.Tot
[ "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" ]
[]
false
false
false
true
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) (buffer_r_alloc #a #(ia, len)) (buffer_r_free #a #(ia, len))
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_copy
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))
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 149, "start_col": 0, "start_line": 148 }
(* 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 /\
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
arg: (a * LowStar.Regional.Instances.nonzero) {arg == FStar.Ghost.reveal arg'} -> src: LowStar.Buffer.buffer a -> dst: LowStar.Buffer.buffer a -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Ghost.erased", "FStar.Pervasives.Native.tuple2", "LowStar.Regional.Instances.nonzero", "Prims.eq2", "FStar.Ghost.reveal", "LowStar.Buffer.buffer", "LowStar.Monotonic.Buffer.blit", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.__uint_to_t", "Prims.unit" ]
[]
false
true
false
false
false
let buffer_copy #a #_ (ia, len) src dst =
B.blit src 0ul dst 0ul len
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_r_repr
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)
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 210, "start_col": 0, "start_line": 210 }
(* 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} ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
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)
Prims.GTot
[ "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" ]
[]
false
false
false
false
false
let vector_r_repr #a #rst rg h v =
RV.as_seq h v
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.buffer_copyable
val buffer_copyable: #a:Type -> ia:a -> len:nonzero -> copyable #(a & nonzero) (B.buffer a) (buffer_regional 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))
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 177, "start_col": 0, "start_line": 176 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module LowStar.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 ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ia: a -> len: LowStar.Regional.Instances.nonzero -> LowStar.RVector.copyable (LowStar.Buffer.buffer a) (LowStar.Regional.Instances.buffer_regional ia len)
Prims.Tot
[ "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" ]
[]
false
false
false
false
false
let buffer_copyable #a ia len =
Cpy (buffer_copy #_ #(ia, len))
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_r_sep
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))
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 224, "start_col": 0, "start_line": 222 }
(* 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 /\
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rg: LowStar.Regional.regional rst a -> v: LowStar.RVector.rvector rg -> p: LowStar.Monotonic.Buffer.loc -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires LowStar.Regional.Instances.vector_r_inv rg h0 v /\ LowStar.Monotonic.Buffer.loc_disjoint (LowStar.Monotonic.Buffer.loc_all_regions_from false (LowStar.Regional.Instances.vector_region_of rg v)) p /\ LowStar.Monotonic.Buffer.modifies p h0 h1) (ensures LowStar.Regional.Instances.vector_r_inv rg h1 v /\ LowStar.Regional.Instances.vector_r_repr rg h0 v == LowStar.Regional.Instances.vector_r_repr rg h1 v)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowStar.Regional.regional", "LowStar.RVector.rvector", "LowStar.Monotonic.Buffer.loc", "FStar.Monotonic.HyperStack.mem", "LowStar.RVector.as_seq_preserved", "Prims.unit", "LowStar.RVector.rv_inv_preserved" ]
[]
true
false
true
false
false
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
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.get_multilast_t
val get_multilast_t : a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
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)))
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 87, "end_line": 851, "start_col": 0, "start_line": 844 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
a: Spec.Hash.Definitions.sha2_alg -> m: Hacl.Spec.SHA2.Vec.m_spec -> Type0
Prims.Tot
[ "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" ]
[]
false
false
false
true
true
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)))
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.store_state
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))
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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 597, "start_col": 0, "start_line": 595 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
FStar.HyperStack.ST.Stack
[]
[]
[ "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" ]
[]
false
true
false
false
false
let store_state #a #m st hbuf =
transpose_state st; Lib.IntVector.Serialize.vecs_store_be hbuf st
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.as_t
val as_t (#a: Type) (x: normal a) : a
val as_t (#a: Type) (x: normal a) : a
let as_t (#a:Type) (x:normal a) : a = x
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 32, "start_col": 0, "start_line": 32 }
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 *)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Vale.Interop.Base.normal a -> a
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.normal" ]
[]
false
false
false
true
false
let as_t (#a: Type) (x: normal a) : a =
x
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_regional
val vector_regional: #a:Type0 -> #rst:Type -> rg:regional rst a -> regional (regional rst a) (rvector rg)
val vector_regional: #a:Type0 -> #rst:Type -> rg:regional rst a -> regional (regional rst a) (rvector rg)
let vector_regional #a #rst rg = Rgl rg (vector_region_of #a #rst rg) V.loc_vector (vector_dummy #a #rst rg) (vector_r_inv #a #rst rg) (vector_r_inv_reg #a #rst rg) (vector_repr #a rg) (vector_r_repr #a #rst rg) (vector_r_sep #a #rst rg) (vector_irepr #a rg) (vector_r_alloc_p #a #rst rg) (vector_r_alloc #a #rst) (vector_r_free #a #rst #rg)
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 277, "start_col": 0, "start_line": 264 }
(* 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)) let vector_r_free #_ #_ _ v = V.free v val vector_regional:
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rg: LowStar.Regional.regional rst a -> LowStar.Regional.regional (LowStar.Regional.regional rst a) (LowStar.RVector.rvector rg)
Prims.Tot
[ "total" ]
[]
[ "LowStar.Regional.regional", "LowStar.Regional.Rgl", "LowStar.RVector.rvector", "LowStar.Regional.Instances.vector_region_of", "LowStar.Vector.loc_vector", "LowStar.Regional.Instances.vector_dummy", "FStar.Ghost.hide", "LowStar.Regional.Instances.vector_r_inv", "LowStar.Regional.Instances.vector_r_inv_reg", "LowStar.Regional.Instances.vector_repr", "LowStar.Regional.Instances.vector_r_repr", "LowStar.Regional.Instances.vector_r_sep", "LowStar.Regional.Instances.vector_irepr", "LowStar.Regional.Instances.vector_r_alloc_p", "LowStar.Regional.Instances.vector_r_alloc", "LowStar.Regional.Instances.vector_r_free" ]
[]
false
false
false
false
false
let vector_regional #a #rst rg =
Rgl rg (vector_region_of #a #rst rg) V.loc_vector (vector_dummy #a #rst rg) (vector_r_inv #a #rst rg) (vector_r_inv_reg #a #rst rg) (vector_repr #a rg) (vector_r_repr #a #rst rg) (vector_r_sep #a #rst rg) (vector_irepr #a rg) (vector_r_alloc_p #a #rst rg) (vector_r_alloc #a #rst) (vector_r_free #a #rst #rg)
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.as_normal_t
val as_normal_t (#a: Type) (x: a) : normal a
val as_normal_t (#a: Type) (x: a) : normal a
let as_normal_t (#a:Type) (x:a) : normal a = x
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 34, "start_col": 0, "start_line": 34 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Vale.Interop.Base.normal a
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.normal" ]
[]
false
false
false
true
false
let as_normal_t (#a: Type) (x: a) : normal a =
x
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_r_free
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))
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 = V.free v
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 260, "start_col": 0, "start_line": 259 }
(* 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 ->
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowStar.Regional.regional rst a {s == FStar.Ghost.reveal rg} -> v: LowStar.RVector.rvector (FStar.Ghost.reveal rg) -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Ghost.erased", "LowStar.Regional.regional", "Prims.eq2", "FStar.Ghost.reveal", "LowStar.RVector.rvector", "LowStar.Vector.free", "Prims.unit" ]
[]
false
true
false
false
false
let vector_r_free #_ #_ _ v =
V.free v
false
LowStar.Regional.Instances.fst
LowStar.Regional.Instances.vector_r_alloc
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)))
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
{ "file_name": "ulib/LowStar.Regional.Instances.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 251, "start_col": 0, "start_line": 249 }
(* 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 /\
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rg: LowStar.Regional.regional rst a -> r: FStar.HyperStack.ST.erid -> FStar.HyperStack.ST.ST (LowStar.RVector.rvector rg)
FStar.HyperStack.ST.ST
[]
[]
[ "LowStar.Regional.regional", "FStar.HyperStack.ST.erid", "LowStar.Vector.alloc_reserve", "FStar.UInt32.__uint_to_t", "LowStar.Regional.rg_dummy", "LowStar.Vector.vector", "FStar.Monotonic.HyperHeap.rid", "FStar.HyperStack.ST.new_region", "LowStar.RVector.rvector" ]
[]
false
true
false
false
false
let vector_r_alloc #a #rst rg r =
let nrid = HST.new_region r in V.alloc_reserve 1ul (rg_dummy rg) r
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.emit8_spec
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)
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) = 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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 707, "start_col": 0, "start_line": 694 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.get_multiblock
val get_multiblock: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multiblock_t a m
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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 840, "start_col": 0, "start_line": 806 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Hacl.Impl.SHA2.Core.get_multiblock_t a m
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Steel.PCMReference.fsti
Steel.PCMReference.pts_to
val pts_to : r: Steel.Memory.ref a pcm -> v: a -> Steel.Effect.Common.vprop
let pts_to (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v:a) = to_vprop (pts_to r v)
{ "file_name": "lib/steel/Steel.PCMReference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 77, "end_line": 35, "start_col": 0, "start_line": 35 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.PCMReference open FStar.PCM open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect /// This module exposes the core PCM-based memory model defined in Steel.Memory /// as stateful Steel computations. #set-options "--ide_id_info_off" /// Lifting the pts_to separation logic, PCM-indexed predicate to a vprop. /// Its selector is non-informative (it is unit) [@@ __steel_reduce__]
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.PCMReference.fsti" }
[ { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.Memory.ref a pcm -> v: a -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "Steel.Memory.ref", "Steel.Effect.Common.to_vprop", "Steel.Memory.pts_to", "Steel.Effect.Common.vprop" ]
[]
false
false
false
false
false
let pts_to (#a: Type) (#pcm: pcm a) (r: ref a pcm) (v: a) =
to_vprop (pts_to r v)
false
Steel.PCMReference.fsti
Steel.PCMReference.fact_valid_compat
val fact_valid_compat : fact: Steel.Memory.stable_property pcm -> v: FStar.Ghost.erased a -> Type0
let fact_valid_compat (#a:Type) (#pcm:pcm a) (fact:stable_property pcm) (v:erased a) = squash (forall z. compatible pcm v z ==> fact z)
{ "file_name": "lib/steel/Steel.PCMReference.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 52, "end_line": 114, "start_col": 0, "start_line": 111 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.PCMReference open FStar.PCM open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect /// This module exposes the core PCM-based memory model defined in Steel.Memory /// as stateful Steel computations. #set-options "--ide_id_info_off" /// Lifting the pts_to separation logic, PCM-indexed predicate to a vprop. /// Its selector is non-informative (it is unit) [@@ __steel_reduce__] unfold let pts_to (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v:a) = to_vprop (pts_to r v) /// Reading the contents of reference [r] in memory. /// The returned value [v] is ensured to be compatible with respect /// to the PCM [pcm] with our current knowledge [v0] val read (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) : Steel a (pts_to r v0) (fun _ -> pts_to r v0) (requires fun _ -> True) (ensures fun _ v _ -> compatible pcm v0 v /\ True) /// Writing value [v1] in reference [r], as long as it is frame-preserving with our /// current knowledge [v0], and that [v1] is a refined value for the PCM [pcm] val write (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) (v1:a) : Steel unit (pts_to r v0) (fun _ -> pts_to r v1) (requires fun _ -> frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ _ _ -> True) /// Allocates a new reference, initially storing value [x]. val alloc (#a:Type) (#pcm:pcm a) (x:a) : Steel (ref a pcm) emp (fun r -> pts_to r x) (requires fun _ -> pcm.refine x) (ensures fun _ _ _ -> True) /// Frees reference [r], as long as we have exclusive ownership of [r] /// according to the governing PCM. /// Freeing here sets the value to the unit value of the PCM, one can manually /// call `drop` from Steel.Effect.Atomic to forget it entirely from the context val free (#a:Type) (#p:pcm a) (r:ref a p) (x:erased a) : Steel unit (pts_to r x) (fun _ -> pts_to r p.p.one) (requires fun _ -> exclusive p x /\ p.refine p.p.one) (ensures fun _ _ _ -> True) /// Splits permission on reference [r], in a way that is compatible with the governing PCM. val split (#inames: _) (#a:Type) (#p:pcm a) (r:ref a p) (v:erased a) (v0:erased a) (v1:erased a) : SteelGhost unit inames (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == hide (op p v0 v1)) (ensures fun _ _ _ -> True) /// Gather permissions on reference [r] val gather (#inames: _) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:erased a) (v1:erased a) : SteelGhostT (_:unit{composable p v0 v1}) inames (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1))
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.PCMReference.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fact: Steel.Memory.stable_property pcm -> v: FStar.Ghost.erased a -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.PCM.pcm", "Steel.Memory.stable_property", "FStar.Ghost.erased", "Prims.squash", "Prims.l_Forall", "Prims.l_imp", "FStar.PCM.compatible", "FStar.Ghost.reveal" ]
[]
false
false
false
false
true
let fact_valid_compat (#a: Type) (#pcm: pcm a) (fact: stable_property pcm) (v: erased a) =
squash (forall z. compatible pcm v z ==> fact z)
false
Test.Vectors.fst
Test.Vectors.hkdf_vectors_tmp
val hkdf_vectors_tmp : Prims.list (((((Test.Vectors.hash_alg * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded)
let hkdf_vectors_tmp = List.Tot.map (fun h -> h.ha, h.ikm, h.salt, h.info, h.prk, h.okm ) hkdf_vectors
{ "file_name": "providers/test/Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 259, "start_col": 0, "start_line": 257 }
module Test.Vectors open Test.Lowstarize open EverCrypt.Hash open Spec.Hash.Definitions /// Hash algorithms type hash_alg = EverCrypt.Hash.alg #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" noeq noextract type hash_vector = { (* The input [input] is repeated [repeat] times. *) hash_alg: hash_alg; input: string; output: hex_encoded; repeat: UInt32.t; } noextract let hash_vectors = [{ hash_alg = MD5; input = ""; output = h"d41d8cd98f00b204e9800998ecf8427e"; repeat = 1ul }; { hash_alg = MD5; input = "a"; output = h"0cc175b9c0f1b6a831c399e269772661"; repeat = 1ul }; { hash_alg = MD5; input = "abc"; output = h"900150983cd24fb0d6963f7d28e17f72"; repeat = 1ul }; { hash_alg = MD5; input = "message digest"; output = h"f96b697d7cb7938d525a2f31aaf161d0"; repeat = 1ul }; { hash_alg = MD5; input = "abcdefghijklmnopqrstuvwxyz"; output = h"c3fcd3d76192e4007dfb496cca67e13b"; repeat = 1ul }; { hash_alg = MD5; input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; output = h"d174ab98d277d9f5a5611c2c9f419d9f"; repeat = 1ul }; { hash_alg = MD5; input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; output = h"57edf4a22be3c955ac49da2e2107b67a"; repeat = 1ul }; { hash_alg = SHA1; input = "abc"; output = h"a9993e364706816aba3e25717850c26c9cd0d89d"; repeat = 1ul }; { hash_alg = SHA1; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"84983e441c3bd26ebaae4aa1f95129e5e54670f1"; repeat = 1ul }; { hash_alg = SHA1; input = "a"; output = h"34aa973cd4c4daa4f61eeb2bdbad27316534016f"; repeat = 1000000ul }; { hash_alg = SHA1; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"dea356a2cddd90c7a7ecedc5ebb563934f460452"; repeat = 10ul }; { hash_alg = SHA2_256; input = "abc"; output = h"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; repeat = 1ul }; { hash_alg = SHA2_256; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; repeat = 1ul }; { hash_alg = SHA2_256; input = "a"; output = h"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"; repeat = 1000000ul }; { hash_alg = SHA2_256; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5"; repeat = 10ul }; { hash_alg = SHA2_256; input = "\x19"; output = h"68aa2e2ee5dff96e3355e6c7ee373e3d6a4e17f75f9518d843709c0c9bc3e3d4"; repeat = 1ul };(* { hash_alg = SHA2_256; // 2018.05.26: Don't know how to encode byte literals in strings; this doesn't work // as in OCaml input = "\xe3\xd7\x25\x70\xdc\xdd\x78\x7c\xe3\x88\x7a\xb2\xcd\x68\x46\x52"; output = h"175ee69b02ba9b58e2b0a5fd13819cea573f3940a94f825128cf4209beabb4e8"; repeat = 1ul }; *){ hash_alg = SHA2_384; input = "abc"; output = h"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"; repeat = 1ul }; { hash_alg = SHA2_384; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"; repeat = 1ul }; { hash_alg = SHA2_384; input = "a"; output = h"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"; repeat = 1000000ul }; { hash_alg = SHA2_384; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"2fc64a4f500ddb6828f6a3430b8dd72a368eb7f3a8322a70bc84275b9c0b3ab00d27a5cc3c2d224aa6b61a0d79fb4596"; repeat = 10ul }; { hash_alg = SHA2_512; input = "abc"; output = h"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"; repeat = 1ul }; { hash_alg = SHA2_512; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"; repeat = 1ul }; { hash_alg = SHA2_512; input = "a"; output = h"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"; repeat = 1000000ul }; { hash_alg = SHA2_512; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"89d05ba632c699c31231ded4ffc127d5a894dad412c0e024db872d1abd2ba8141a0f85072a9be1e2aa04cf33c765cb510813a39cd5a84c4acaa64d3f3fb7bae9"; repeat = 10ul } ] noextract let hash_vectors_tmp = List.Tot.map (fun h -> h.hash_alg, h.input, h.output, h.repeat ) hash_vectors // 2018.08.06 SZ: I can't verify this in interactive mode but verifies from the command-line %splice[] (lowstarize_toplevel "hash_vectors_tmp" "hash_vectors_low") /// HMAC noeq noextract type hmac_vector = { ha: hash_alg; key: hex_encoded; data: hex_encoded; output: hex_encoded; } // selected test vectors from // https://tools.ietf.org/html/rfc4231#section-4.2 // pls extend me! noextract let hmac_vectors = [{ ha = SHA2_256; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"; }; { ha = SHA2_384; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6"; }] noextract let hmac_vectors_tmp = List.Tot.map (fun h -> h.ha, h.key, h.data, h.output ) hmac_vectors %splice[] (lowstarize_toplevel "hmac_vectors_tmp" "hmac_vectors_low") /// HMAC_DRBG noextract let hmac_drbg_vectors_tmp = let open Spec.HMAC_DRBG.Test.Vectors in List.Tot.map (fun x -> x.a, h x.entropy_input, h x.nonce, h x.personalization_string, h x.entropy_input_reseed, h x.additional_input_reseed, (h x.additional_input_1, h x.additional_input_2), h x.returned_bits) test_vectors %splice[] (lowstarize_toplevel "hmac_drbg_vectors_tmp" "hmac_drbg_vectors_low") /// HKDF /// https://tools.ietf.org/html/rfc5869.html /// pls extend me! We miss SHA2_384 and SHA2_512 tests /// /// The test is in 2 steps: /// prk <- extract sal ikm /// okm <- expand prk info okmlen noeq noextract type hkdf_vector = { ha: hash_alg; ikm: hex_encoded; // input key materials salt: hex_encoded; // input salt info: hex_encoded; // expansion label prk: hex_encoded; // extracted pseudo-random key (its length is Spec.Hash.Definitions.hash_len ha) okm: hex_encoded; // output: expanded key materials (its length is an input) } noextract let hkdf_vectors = [{ // Test Case 1 // Basic test case with SHA-256 ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h"000102030405060708090a0b0c";// (13 octets) info = h"f0f1f2f3f4f5f6f7f8f9";// (10 octets) prk = h"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5";// (32 octets) okm = h"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865";// (42 octets) }; { // Test Case 2 // Test with SHA-256 and longer inputs/outputs ha = SHA2_256; ikm = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f";// (80 octets) salt = h"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf";// (80 octets) info = h"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";// (80 octets) prk = h"06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244";// (32 octets) okm = h"b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87";// (82 octets) }; { // Test Case 3 // Test with SHA-256 and zero-length salt/info ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h""; info = h""; prk = h"19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04";// (32 octets) okm = h"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8";// (42 octets) }]
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "EverCrypt.Hash.fsti.checked" ], "interface_file": false, "source_file": "Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list (((((Test.Vectors.hash_alg * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded)
Prims.Tot
[ "total" ]
[]
[ "FStar.List.Tot.Base.map", "Test.Vectors.hkdf_vector", "FStar.Pervasives.Native.tuple6", "Test.Vectors.hash_alg", "Test.Lowstarize.hex_encoded", "FStar.Pervasives.Native.Mktuple6", "Test.Vectors.__proj__Mkhkdf_vector__item__ha", "Test.Vectors.__proj__Mkhkdf_vector__item__ikm", "Test.Vectors.__proj__Mkhkdf_vector__item__salt", "Test.Vectors.__proj__Mkhkdf_vector__item__info", "Test.Vectors.__proj__Mkhkdf_vector__item__prk", "Test.Vectors.__proj__Mkhkdf_vector__item__okm", "Test.Vectors.hkdf_vectors" ]
[]
false
false
false
true
false
let hkdf_vectors_tmp =
List.Tot.map (fun h -> h.ha, h.ikm, h.salt, h.info, h.prk, h.okm) hkdf_vectors
false
Hacl.HKDF.fsti
Hacl.HKDF.hash_block_length_fits
val hash_block_length_fits (a: fixed_len_alg) : Lemma ((hash_length a + pow2 32 + block_length a) `less_strict_than_max_input_length` a)
val hash_block_length_fits (a: fixed_len_alg) : Lemma ((hash_length a + pow2 32 + block_length a) `less_strict_than_max_input_length` a)
let hash_block_length_fits (a:fixed_len_alg) : Lemma ((hash_length a + pow2 32 + block_length a) `less_strict_than_max_input_length` a) = let open FStar.Mul in assert_norm (8 * 16 + 8 * 8 + pow2 32 < pow2 61); assert_norm (pow2 61 < pow2 125)
{ "file_name": "code/hkdf/Hacl.HKDF.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 38, "start_col": 0, "start_line": 33 }
module Hacl.HKDF /// A generic, meta-programmed HKDF module. It provides one concrete /// instantiation, namely HKDF-SHA2-256 instantiated with the HACL* /// implementation. In the future, this module may provide more implementations /// using optimized HACL versions of SHA2-256. For more algorithms, and /// for an assembly-optimized HKDF version that may call into Vale, see /// EverCrypt.HKDF. module B = LowStar.Buffer open Spec.Hash.Definitions open Spec.Agile.HKDF open FStar.HyperStack.ST open Lib.IntTypes #set-options "--z3rlimit 20 --fuel 0 --ifuel 0" inline_for_extraction noextract let less_strict_than_max_input_length l a = match max_input_length a with | Some max -> l < max | None -> true let key_and_data_fits (a:fixed_len_alg) : Lemma ((block_length a + pow2 32) `less_than_max_input_length` a) = let open FStar.Mul in assert_norm (8 * 16 + pow2 32 < pow2 61); assert_norm (pow2 61 < pow2 125)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.HMAC.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "Hacl.HKDF.fsti" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.fixed_len_alg -> FStar.Pervasives.Lemma (ensures Hacl.HKDF.less_strict_than_max_input_length (Spec.Hash.Definitions.hash_length a + Prims.pow2 32 + Spec.Hash.Definitions.block_length a) a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.Hash.Definitions.fixed_len_alg", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.unit", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.l_True", "Prims.squash", "Hacl.HKDF.less_strict_than_max_input_length", "Spec.Hash.Definitions.hash_length", "Spec.Hash.Definitions.block_length", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let hash_block_length_fits (a: fixed_len_alg) : Lemma ((hash_length a + pow2 32 + block_length a) `less_strict_than_max_input_length` a) =
let open FStar.Mul in assert_norm (8 * 16 + 8 * 8 + pow2 32 < pow2 61); assert_norm (pow2 61 < pow2 125)
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_post
val gcm128_post: Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom
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 = 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
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 123, "start_col": 0, "start_line": 90 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.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
Prims.Tot
[ "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" ]
[]
false
false
false
true
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
false
Hacl.HKDF.fsti
Hacl.HKDF.less_strict_than_max_input_length
val less_strict_than_max_input_length : l: Prims.int -> a: Spec.Hash.Definitions.hash_alg -> Prims.bool
let less_strict_than_max_input_length l a = match max_input_length a with | Some max -> l < max | None -> true
{ "file_name": "code/hkdf/Hacl.HKDF.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 24, "start_col": 0, "start_line": 21 }
module Hacl.HKDF /// A generic, meta-programmed HKDF module. It provides one concrete /// instantiation, namely HKDF-SHA2-256 instantiated with the HACL* /// implementation. In the future, this module may provide more implementations /// using optimized HACL versions of SHA2-256. For more algorithms, and /// for an assembly-optimized HKDF version that may call into Vale, see /// EverCrypt.HKDF. module B = LowStar.Buffer open Spec.Hash.Definitions open Spec.Agile.HKDF open FStar.HyperStack.ST open Lib.IntTypes #set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.HMAC.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "Hacl.HKDF.fsti" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.int -> a: Spec.Hash.Definitions.hash_alg -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Spec.Hash.Definitions.hash_alg", "Spec.Hash.Definitions.max_input_length", "Prims.pos", "Prims.op_LessThan", "Prims.bool" ]
[]
false
false
false
true
false
let less_strict_than_max_input_length l a =
match max_input_length a with | Some max -> l < max | None -> true
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm128
val lowstar_gcm128 (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) : lowstar_gcm128_t s iv
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 = 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))
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 81, "end_line": 224, "start_col": 0, "start_line": 219 }
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 *)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
false
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))
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.dom
val dom:dom: list td {List.length dom <= 20}
val dom:dom: list td {List.length dom <= 20}
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
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 52, "start_col": 0, "start_line": 48 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dom: Prims.list Vale.Interop.Base.td {FStar.List.Tot.Base.length dom <= 20}
Prims.Tot
[ "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" ]
[]
false
false
false
false
false
let dom: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
false
Hacl.HKDF.fsti
Hacl.HKDF.extract_st
val extract_st : a: Spec.Hash.Definitions.fixed_len_alg -> Type0
let extract_st (a:fixed_len_alg) = prk : B.buffer uint8 -> salt : B.buffer uint8 -> saltlen : pub_uint32 -> ikm : B.buffer uint8 -> ikmlen : pub_uint32 -> Stack unit (requires fun h0 -> B.live h0 prk /\ B.live h0 salt /\ B.live h0 ikm /\ B.disjoint salt prk /\ B.disjoint ikm prk /\ B.length prk == hash_length a /\ v saltlen == B.length salt /\ v ikmlen == B.length ikm /\ Spec.Agile.HMAC.keysized a (v saltlen) /\ B.length ikm + block_length a < pow2 32) (ensures fun h0 _ h1 -> key_and_data_fits a; B.modifies (B.loc_buffer prk) h0 h1 /\ B.as_seq h1 prk == extract a (B.as_seq h0 salt) (B.as_seq h0 ikm))
{ "file_name": "code/hkdf/Hacl.HKDF.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 70, "end_line": 59, "start_col": 0, "start_line": 41 }
module Hacl.HKDF /// A generic, meta-programmed HKDF module. It provides one concrete /// instantiation, namely HKDF-SHA2-256 instantiated with the HACL* /// implementation. In the future, this module may provide more implementations /// using optimized HACL versions of SHA2-256. For more algorithms, and /// for an assembly-optimized HKDF version that may call into Vale, see /// EverCrypt.HKDF. module B = LowStar.Buffer open Spec.Hash.Definitions open Spec.Agile.HKDF open FStar.HyperStack.ST open Lib.IntTypes #set-options "--z3rlimit 20 --fuel 0 --ifuel 0" inline_for_extraction noextract let less_strict_than_max_input_length l a = match max_input_length a with | Some max -> l < max | None -> true let key_and_data_fits (a:fixed_len_alg) : Lemma ((block_length a + pow2 32) `less_than_max_input_length` a) = let open FStar.Mul in assert_norm (8 * 16 + pow2 32 < pow2 61); assert_norm (pow2 61 < pow2 125) let hash_block_length_fits (a:fixed_len_alg) : Lemma ((hash_length a + pow2 32 + block_length a) `less_strict_than_max_input_length` a) = let open FStar.Mul in assert_norm (8 * 16 + 8 * 8 + pow2 32 < pow2 61); assert_norm (pow2 61 < pow2 125)
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.HMAC.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "Hacl.HKDF.fsti" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.fixed_len_alg -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.fixed_len_alg", "LowStar.Buffer.buffer", "Lib.IntTypes.uint8", "Lib.IntTypes.pub_uint32", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.disjoint", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "Spec.Hash.Definitions.hash_length", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Spec.Agile.HMAC.keysized", "Prims.op_LessThan", "Prims.op_Addition", "Spec.Hash.Definitions.block_length", "Prims.pow2", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_buffer", "FStar.Seq.Base.seq", "LowStar.Monotonic.Buffer.as_seq", "Spec.Agile.HKDF.extract", "Hacl.HKDF.key_and_data_fits" ]
[]
false
false
false
true
true
let extract_st (a: fixed_len_alg) =
prk: B.buffer uint8 -> salt: B.buffer uint8 -> saltlen: pub_uint32 -> ikm: B.buffer uint8 -> ikmlen: pub_uint32 -> Stack unit (requires fun h0 -> B.live h0 prk /\ B.live h0 salt /\ B.live h0 ikm /\ B.disjoint salt prk /\ B.disjoint ikm prk /\ B.length prk == hash_length a /\ v saltlen == B.length salt /\ v ikmlen == B.length ikm /\ Spec.Agile.HMAC.keysized a (v saltlen) /\ B.length ikm + block_length a < pow2 32) (ensures fun h0 _ h1 -> key_and_data_fits a; B.modifies (B.loc_buffer prk) h0 h1 /\ B.as_seq h1 prk == extract a (B.as_seq h0 salt) (B.as_seq h0 ikm))
false
Hacl.HKDF.fsti
Hacl.HKDF.expand_st
val expand_st : a: Spec.Hash.Definitions.fixed_len_alg -> Type0
let expand_st (a:fixed_len_alg) = okm : B.buffer uint8 -> prk : B.buffer uint8 -> prklen : pub_uint32 -> info : B.buffer uint8 -> infolen : pub_uint32 -> len : pub_uint32 -> Stack unit (requires fun h0 -> B.live h0 okm /\ B.live h0 prk /\ B.live h0 info /\ B.disjoint okm prk /\ v prklen == B.length prk /\ v infolen == B.length info /\ v len == B.length okm /\ hash_length a <= v prklen /\ Spec.Agile.HMAC.keysized a (v prklen) /\ hash_length a + v infolen + 1 + block_length a < pow2 32 /\ v len <= FStar.Mul.(255 * hash_length a)) (ensures fun h0 _ h1 -> hash_block_length_fits a; B.modifies (B.loc_buffer okm) h0 h1 /\ B.as_seq h1 okm == expand a (B.as_seq h0 prk) (B.as_seq h0 info) (v len))
{ "file_name": "code/hkdf/Hacl.HKDF.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 77, "end_line": 83, "start_col": 0, "start_line": 62 }
module Hacl.HKDF /// A generic, meta-programmed HKDF module. It provides one concrete /// instantiation, namely HKDF-SHA2-256 instantiated with the HACL* /// implementation. In the future, this module may provide more implementations /// using optimized HACL versions of SHA2-256. For more algorithms, and /// for an assembly-optimized HKDF version that may call into Vale, see /// EverCrypt.HKDF. module B = LowStar.Buffer open Spec.Hash.Definitions open Spec.Agile.HKDF open FStar.HyperStack.ST open Lib.IntTypes #set-options "--z3rlimit 20 --fuel 0 --ifuel 0" inline_for_extraction noextract let less_strict_than_max_input_length l a = match max_input_length a with | Some max -> l < max | None -> true let key_and_data_fits (a:fixed_len_alg) : Lemma ((block_length a + pow2 32) `less_than_max_input_length` a) = let open FStar.Mul in assert_norm (8 * 16 + pow2 32 < pow2 61); assert_norm (pow2 61 < pow2 125) let hash_block_length_fits (a:fixed_len_alg) : Lemma ((hash_length a + pow2 32 + block_length a) `less_strict_than_max_input_length` a) = let open FStar.Mul in assert_norm (8 * 16 + 8 * 8 + pow2 32 < pow2 61); assert_norm (pow2 61 < pow2 125) inline_for_extraction noextract let extract_st (a:fixed_len_alg) = prk : B.buffer uint8 -> salt : B.buffer uint8 -> saltlen : pub_uint32 -> ikm : B.buffer uint8 -> ikmlen : pub_uint32 -> Stack unit (requires fun h0 -> B.live h0 prk /\ B.live h0 salt /\ B.live h0 ikm /\ B.disjoint salt prk /\ B.disjoint ikm prk /\ B.length prk == hash_length a /\ v saltlen == B.length salt /\ v ikmlen == B.length ikm /\ Spec.Agile.HMAC.keysized a (v saltlen) /\ B.length ikm + block_length a < pow2 32) (ensures fun h0 _ h1 -> key_and_data_fits a; B.modifies (B.loc_buffer prk) h0 h1 /\ B.as_seq h1 prk == extract a (B.as_seq h0 salt) (B.as_seq h0 ikm))
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.HMAC.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "Hacl.HKDF.fsti" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.fixed_len_alg -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.fixed_len_alg", "LowStar.Buffer.buffer", "Lib.IntTypes.uint8", "Lib.IntTypes.pub_uint32", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.disjoint", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "LowStar.Monotonic.Buffer.length", "Prims.op_LessThanOrEqual", "Spec.Hash.Definitions.hash_length", "Spec.Agile.HMAC.keysized", "Prims.op_LessThan", "Prims.op_Addition", "Spec.Hash.Definitions.block_length", "Prims.pow2", "FStar.Mul.op_Star", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_buffer", "FStar.Seq.Base.seq", "LowStar.Monotonic.Buffer.as_seq", "Spec.Agile.HKDF.expand", "Hacl.HKDF.hash_block_length_fits" ]
[]
false
false
false
true
true
let expand_st (a: fixed_len_alg) =
okm: B.buffer uint8 -> prk: B.buffer uint8 -> prklen: pub_uint32 -> info: B.buffer uint8 -> infolen: pub_uint32 -> len: pub_uint32 -> Stack unit (requires fun h0 -> B.live h0 okm /\ B.live h0 prk /\ B.live h0 info /\ B.disjoint okm prk /\ v prklen == B.length prk /\ v infolen == B.length info /\ v len == B.length okm /\ hash_length a <= v prklen /\ Spec.Agile.HMAC.keysized a (v prklen) /\ hash_length a + v infolen + 1 + block_length a < pow2 32 /\ v len <= FStar.Mul.(255 * hash_length a)) (ensures fun h0 _ h1 -> hash_block_length_fits a; B.modifies (B.loc_buffer okm) h0 h1 /\ B.as_seq h1 okm == expand a (B.as_seq h0 prk) (B.as_seq h0 info) (v len))
false
Test.Vectors.fst
Test.Vectors.block_cipher_vectors
val block_cipher_vectors : Prims.list Test.Vectors.block_cipher_vector
let block_cipher_vectors = [ { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"3ad77bb40d7a3660a89ecaf32466ef97" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"f5d3d58503b9699de785895a96fdbaaf" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"43b1cd7f598ece23881b00e3ed030688" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"7b0c785e27e8ad3f8223207104725dd4" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"f3eed1bdb5d2a03c064b5a7e3db181f8" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"591ccb10d410ed26dc5ba74a31362870" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"b6ed21b99ca6f4f9f153e7b1beafed1d" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"23304b7a39f9f3ff067d8d8f9e24ecc7" }]
{ "file_name": "providers/test/Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 323, "start_col": 0, "start_line": 282 }
module Test.Vectors open Test.Lowstarize open EverCrypt.Hash open Spec.Hash.Definitions /// Hash algorithms type hash_alg = EverCrypt.Hash.alg #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" noeq noextract type hash_vector = { (* The input [input] is repeated [repeat] times. *) hash_alg: hash_alg; input: string; output: hex_encoded; repeat: UInt32.t; } noextract let hash_vectors = [{ hash_alg = MD5; input = ""; output = h"d41d8cd98f00b204e9800998ecf8427e"; repeat = 1ul }; { hash_alg = MD5; input = "a"; output = h"0cc175b9c0f1b6a831c399e269772661"; repeat = 1ul }; { hash_alg = MD5; input = "abc"; output = h"900150983cd24fb0d6963f7d28e17f72"; repeat = 1ul }; { hash_alg = MD5; input = "message digest"; output = h"f96b697d7cb7938d525a2f31aaf161d0"; repeat = 1ul }; { hash_alg = MD5; input = "abcdefghijklmnopqrstuvwxyz"; output = h"c3fcd3d76192e4007dfb496cca67e13b"; repeat = 1ul }; { hash_alg = MD5; input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; output = h"d174ab98d277d9f5a5611c2c9f419d9f"; repeat = 1ul }; { hash_alg = MD5; input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; output = h"57edf4a22be3c955ac49da2e2107b67a"; repeat = 1ul }; { hash_alg = SHA1; input = "abc"; output = h"a9993e364706816aba3e25717850c26c9cd0d89d"; repeat = 1ul }; { hash_alg = SHA1; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"84983e441c3bd26ebaae4aa1f95129e5e54670f1"; repeat = 1ul }; { hash_alg = SHA1; input = "a"; output = h"34aa973cd4c4daa4f61eeb2bdbad27316534016f"; repeat = 1000000ul }; { hash_alg = SHA1; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"dea356a2cddd90c7a7ecedc5ebb563934f460452"; repeat = 10ul }; { hash_alg = SHA2_256; input = "abc"; output = h"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; repeat = 1ul }; { hash_alg = SHA2_256; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; repeat = 1ul }; { hash_alg = SHA2_256; input = "a"; output = h"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"; repeat = 1000000ul }; { hash_alg = SHA2_256; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5"; repeat = 10ul }; { hash_alg = SHA2_256; input = "\x19"; output = h"68aa2e2ee5dff96e3355e6c7ee373e3d6a4e17f75f9518d843709c0c9bc3e3d4"; repeat = 1ul };(* { hash_alg = SHA2_256; // 2018.05.26: Don't know how to encode byte literals in strings; this doesn't work // as in OCaml input = "\xe3\xd7\x25\x70\xdc\xdd\x78\x7c\xe3\x88\x7a\xb2\xcd\x68\x46\x52"; output = h"175ee69b02ba9b58e2b0a5fd13819cea573f3940a94f825128cf4209beabb4e8"; repeat = 1ul }; *){ hash_alg = SHA2_384; input = "abc"; output = h"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"; repeat = 1ul }; { hash_alg = SHA2_384; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"; repeat = 1ul }; { hash_alg = SHA2_384; input = "a"; output = h"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"; repeat = 1000000ul }; { hash_alg = SHA2_384; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"2fc64a4f500ddb6828f6a3430b8dd72a368eb7f3a8322a70bc84275b9c0b3ab00d27a5cc3c2d224aa6b61a0d79fb4596"; repeat = 10ul }; { hash_alg = SHA2_512; input = "abc"; output = h"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"; repeat = 1ul }; { hash_alg = SHA2_512; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"; repeat = 1ul }; { hash_alg = SHA2_512; input = "a"; output = h"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"; repeat = 1000000ul }; { hash_alg = SHA2_512; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"89d05ba632c699c31231ded4ffc127d5a894dad412c0e024db872d1abd2ba8141a0f85072a9be1e2aa04cf33c765cb510813a39cd5a84c4acaa64d3f3fb7bae9"; repeat = 10ul } ] noextract let hash_vectors_tmp = List.Tot.map (fun h -> h.hash_alg, h.input, h.output, h.repeat ) hash_vectors // 2018.08.06 SZ: I can't verify this in interactive mode but verifies from the command-line %splice[] (lowstarize_toplevel "hash_vectors_tmp" "hash_vectors_low") /// HMAC noeq noextract type hmac_vector = { ha: hash_alg; key: hex_encoded; data: hex_encoded; output: hex_encoded; } // selected test vectors from // https://tools.ietf.org/html/rfc4231#section-4.2 // pls extend me! noextract let hmac_vectors = [{ ha = SHA2_256; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"; }; { ha = SHA2_384; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6"; }] noextract let hmac_vectors_tmp = List.Tot.map (fun h -> h.ha, h.key, h.data, h.output ) hmac_vectors %splice[] (lowstarize_toplevel "hmac_vectors_tmp" "hmac_vectors_low") /// HMAC_DRBG noextract let hmac_drbg_vectors_tmp = let open Spec.HMAC_DRBG.Test.Vectors in List.Tot.map (fun x -> x.a, h x.entropy_input, h x.nonce, h x.personalization_string, h x.entropy_input_reseed, h x.additional_input_reseed, (h x.additional_input_1, h x.additional_input_2), h x.returned_bits) test_vectors %splice[] (lowstarize_toplevel "hmac_drbg_vectors_tmp" "hmac_drbg_vectors_low") /// HKDF /// https://tools.ietf.org/html/rfc5869.html /// pls extend me! We miss SHA2_384 and SHA2_512 tests /// /// The test is in 2 steps: /// prk <- extract sal ikm /// okm <- expand prk info okmlen noeq noextract type hkdf_vector = { ha: hash_alg; ikm: hex_encoded; // input key materials salt: hex_encoded; // input salt info: hex_encoded; // expansion label prk: hex_encoded; // extracted pseudo-random key (its length is Spec.Hash.Definitions.hash_len ha) okm: hex_encoded; // output: expanded key materials (its length is an input) } noextract let hkdf_vectors = [{ // Test Case 1 // Basic test case with SHA-256 ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h"000102030405060708090a0b0c";// (13 octets) info = h"f0f1f2f3f4f5f6f7f8f9";// (10 octets) prk = h"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5";// (32 octets) okm = h"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865";// (42 octets) }; { // Test Case 2 // Test with SHA-256 and longer inputs/outputs ha = SHA2_256; ikm = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f";// (80 octets) salt = h"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf";// (80 octets) info = h"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";// (80 octets) prk = h"06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244";// (32 octets) okm = h"b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87";// (82 octets) }; { // Test Case 3 // Test with SHA-256 and zero-length salt/info ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h""; info = h""; prk = h"19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04";// (32 octets) okm = h"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8";// (42 octets) }] noextract let hkdf_vectors_tmp = List.Tot.map (fun h -> h.ha, h.ikm, h.salt, h.info, h.prk, h.okm ) hkdf_vectors %splice[] (lowstarize_toplevel "hkdf_vectors_tmp" "hkdf_vectors_low") //TODO add test_hkdf, test_hkdf_one as for HMAC /// Cipher block function type block_cipher = | AES128 | AES256 // Funky field names to avoid collisions... noeq noextract type block_cipher_vector = { block: block_cipher; rkey: hex_encoded; plain: hex_encoded; enc: hex_encoded; }
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "EverCrypt.Hash.fsti.checked" ], "interface_file": false, "source_file": "Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Test.Vectors.block_cipher_vector
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "Test.Vectors.block_cipher_vector", "Test.Vectors.Mkblock_cipher_vector", "Test.Vectors.AES128", "Test.Lowstarize.h", "Test.Vectors.AES256", "Prims.Nil" ]
[]
false
false
false
true
false
let block_cipher_vectors =
[ { block = AES128; rkey = h "2b7e151628aed2a6abf7158809cf4f3c"; plain = h "6bc1bee22e409f96e93d7e117393172a"; enc = h "3ad77bb40d7a3660a89ecaf32466ef97" }; { block = AES128; rkey = h "2b7e151628aed2a6abf7158809cf4f3c"; plain = h "ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h "f5d3d58503b9699de785895a96fdbaaf" }; { block = AES128; rkey = h "2b7e151628aed2a6abf7158809cf4f3c"; plain = h "30c81c46a35ce411e5fbc1191a0a52ef"; enc = h "43b1cd7f598ece23881b00e3ed030688" }; { block = AES128; rkey = h "2b7e151628aed2a6abf7158809cf4f3c"; plain = h "f69f2445df4f9b17ad2b417be66c3710"; enc = h "7b0c785e27e8ad3f8223207104725dd4" }; { block = AES256; rkey = h "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h "6bc1bee22e409f96e93d7e117393172a"; enc = h "f3eed1bdb5d2a03c064b5a7e3db181f8" }; { block = AES256; rkey = h "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h "ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h "591ccb10d410ed26dc5ba74a31362870" }; { block = AES256; rkey = h "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h "30c81c46a35ce411e5fbc1191a0a52ef"; enc = h "b6ed21b99ca6f4f9f153e7b1beafed1d" }; { block = AES256; rkey = h "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h "f69f2445df4f9b17ad2b417be66c3710"; enc = h "23304b7a39f9f3ff067d8d8f9e24ecc7" } ]
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm128_t
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
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))
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 81, "end_line": 215, "start_col": 0, "start_line": 207 }
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 *)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
true
true
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))
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_post
val gcm256_post: Ghost.erased (Seq.seq nat32) -> (Ghost.erased supported_iv_LE) -> VSig.vale_post dom
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 = 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
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 295, "start_col": 0, "start_line": 262 }
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)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
true
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
false
Hacl.HKDF.fsti
Hacl.HKDF.key_and_data_fits
val key_and_data_fits (a: fixed_len_alg) : Lemma ((block_length a + pow2 32) `less_than_max_input_length` a)
val key_and_data_fits (a: fixed_len_alg) : Lemma ((block_length a + pow2 32) `less_than_max_input_length` a)
let key_and_data_fits (a:fixed_len_alg) : Lemma ((block_length a + pow2 32) `less_than_max_input_length` a) = let open FStar.Mul in assert_norm (8 * 16 + pow2 32 < pow2 61); assert_norm (pow2 61 < pow2 125)
{ "file_name": "code/hkdf/Hacl.HKDF.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 31, "start_col": 0, "start_line": 26 }
module Hacl.HKDF /// A generic, meta-programmed HKDF module. It provides one concrete /// instantiation, namely HKDF-SHA2-256 instantiated with the HACL* /// implementation. In the future, this module may provide more implementations /// using optimized HACL versions of SHA2-256. For more algorithms, and /// for an assembly-optimized HKDF version that may call into Vale, see /// EverCrypt.HKDF. module B = LowStar.Buffer open Spec.Hash.Definitions open Spec.Agile.HKDF open FStar.HyperStack.ST open Lib.IntTypes #set-options "--z3rlimit 20 --fuel 0 --ifuel 0" inline_for_extraction noextract let less_strict_than_max_input_length l a = match max_input_length a with | Some max -> l < max | None -> true
{ "checked_file": "/", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Agile.HMAC.fsti.checked", "Spec.Agile.HKDF.fsti.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.HMAC.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked" ], "interface_file": false, "source_file": "Hacl.HKDF.fsti" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.HKDF", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.fixed_len_alg -> FStar.Pervasives.Lemma (ensures Spec.Hash.Definitions.less_than_max_input_length (Spec.Hash.Definitions.block_length a + Prims.pow2 32) a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.Hash.Definitions.fixed_len_alg", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.unit", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.l_True", "Prims.squash", "Spec.Hash.Definitions.less_than_max_input_length", "Spec.Hash.Definitions.block_length", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let key_and_data_fits (a: fixed_len_alg) : Lemma ((block_length a + pow2 32) `less_than_max_input_length` a) =
let open FStar.Mul in assert_norm (8 * 16 + pow2 32 < pow2 61); assert_norm (pow2 61 < pow2 125)
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_pre
val gcm128_pre: (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom
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 = 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)
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 74, "end_line": 87, "start_col": 0, "start_line": 56 }
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 *)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.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
Prims.Tot
[ "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" ]
[]
false
false
false
true
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)
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm256_t
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
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))
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 81, "end_line": 387, "start_col": 0, "start_line": 379 }
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 *)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
true
true
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))
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.gcm256_pre
val gcm256_pre: (Ghost.erased (Seq.seq nat32)) -> (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom
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 = 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)
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 74, "end_line": 259, "start_col": 0, "start_line": 228 }
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 *)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
true
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)
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.lowstar_gcm256
val lowstar_gcm256 (s: Ghost.erased (Seq.seq nat32)) (iv: Ghost.erased supported_iv_LE) : lowstar_gcm256_t s iv
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 = 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))
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 81, "end_line": 396, "start_col": 0, "start_line": 391 }
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 *)
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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
Prims.Tot
[ "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" ]
[]
false
false
false
false
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))
false
Test.Vectors.fst
Test.Vectors.block_cipher_vectors_tmp
val block_cipher_vectors_tmp : Prims.list (((Test.Vectors.block_cipher * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded)
let block_cipher_vectors_tmp = List.Tot.map (fun h -> h.block, h.rkey, h.plain, h.enc ) block_cipher_vectors
{ "file_name": "providers/test/Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 328, "start_col": 0, "start_line": 326 }
module Test.Vectors open Test.Lowstarize open EverCrypt.Hash open Spec.Hash.Definitions /// Hash algorithms type hash_alg = EverCrypt.Hash.alg #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" noeq noextract type hash_vector = { (* The input [input] is repeated [repeat] times. *) hash_alg: hash_alg; input: string; output: hex_encoded; repeat: UInt32.t; } noextract let hash_vectors = [{ hash_alg = MD5; input = ""; output = h"d41d8cd98f00b204e9800998ecf8427e"; repeat = 1ul }; { hash_alg = MD5; input = "a"; output = h"0cc175b9c0f1b6a831c399e269772661"; repeat = 1ul }; { hash_alg = MD5; input = "abc"; output = h"900150983cd24fb0d6963f7d28e17f72"; repeat = 1ul }; { hash_alg = MD5; input = "message digest"; output = h"f96b697d7cb7938d525a2f31aaf161d0"; repeat = 1ul }; { hash_alg = MD5; input = "abcdefghijklmnopqrstuvwxyz"; output = h"c3fcd3d76192e4007dfb496cca67e13b"; repeat = 1ul }; { hash_alg = MD5; input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; output = h"d174ab98d277d9f5a5611c2c9f419d9f"; repeat = 1ul }; { hash_alg = MD5; input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; output = h"57edf4a22be3c955ac49da2e2107b67a"; repeat = 1ul }; { hash_alg = SHA1; input = "abc"; output = h"a9993e364706816aba3e25717850c26c9cd0d89d"; repeat = 1ul }; { hash_alg = SHA1; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"84983e441c3bd26ebaae4aa1f95129e5e54670f1"; repeat = 1ul }; { hash_alg = SHA1; input = "a"; output = h"34aa973cd4c4daa4f61eeb2bdbad27316534016f"; repeat = 1000000ul }; { hash_alg = SHA1; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"dea356a2cddd90c7a7ecedc5ebb563934f460452"; repeat = 10ul }; { hash_alg = SHA2_256; input = "abc"; output = h"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; repeat = 1ul }; { hash_alg = SHA2_256; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; repeat = 1ul }; { hash_alg = SHA2_256; input = "a"; output = h"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"; repeat = 1000000ul }; { hash_alg = SHA2_256; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5"; repeat = 10ul }; { hash_alg = SHA2_256; input = "\x19"; output = h"68aa2e2ee5dff96e3355e6c7ee373e3d6a4e17f75f9518d843709c0c9bc3e3d4"; repeat = 1ul };(* { hash_alg = SHA2_256; // 2018.05.26: Don't know how to encode byte literals in strings; this doesn't work // as in OCaml input = "\xe3\xd7\x25\x70\xdc\xdd\x78\x7c\xe3\x88\x7a\xb2\xcd\x68\x46\x52"; output = h"175ee69b02ba9b58e2b0a5fd13819cea573f3940a94f825128cf4209beabb4e8"; repeat = 1ul }; *){ hash_alg = SHA2_384; input = "abc"; output = h"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"; repeat = 1ul }; { hash_alg = SHA2_384; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"; repeat = 1ul }; { hash_alg = SHA2_384; input = "a"; output = h"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"; repeat = 1000000ul }; { hash_alg = SHA2_384; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"2fc64a4f500ddb6828f6a3430b8dd72a368eb7f3a8322a70bc84275b9c0b3ab00d27a5cc3c2d224aa6b61a0d79fb4596"; repeat = 10ul }; { hash_alg = SHA2_512; input = "abc"; output = h"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"; repeat = 1ul }; { hash_alg = SHA2_512; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"; repeat = 1ul }; { hash_alg = SHA2_512; input = "a"; output = h"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"; repeat = 1000000ul }; { hash_alg = SHA2_512; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"89d05ba632c699c31231ded4ffc127d5a894dad412c0e024db872d1abd2ba8141a0f85072a9be1e2aa04cf33c765cb510813a39cd5a84c4acaa64d3f3fb7bae9"; repeat = 10ul } ] noextract let hash_vectors_tmp = List.Tot.map (fun h -> h.hash_alg, h.input, h.output, h.repeat ) hash_vectors // 2018.08.06 SZ: I can't verify this in interactive mode but verifies from the command-line %splice[] (lowstarize_toplevel "hash_vectors_tmp" "hash_vectors_low") /// HMAC noeq noextract type hmac_vector = { ha: hash_alg; key: hex_encoded; data: hex_encoded; output: hex_encoded; } // selected test vectors from // https://tools.ietf.org/html/rfc4231#section-4.2 // pls extend me! noextract let hmac_vectors = [{ ha = SHA2_256; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"; }; { ha = SHA2_384; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6"; }] noextract let hmac_vectors_tmp = List.Tot.map (fun h -> h.ha, h.key, h.data, h.output ) hmac_vectors %splice[] (lowstarize_toplevel "hmac_vectors_tmp" "hmac_vectors_low") /// HMAC_DRBG noextract let hmac_drbg_vectors_tmp = let open Spec.HMAC_DRBG.Test.Vectors in List.Tot.map (fun x -> x.a, h x.entropy_input, h x.nonce, h x.personalization_string, h x.entropy_input_reseed, h x.additional_input_reseed, (h x.additional_input_1, h x.additional_input_2), h x.returned_bits) test_vectors %splice[] (lowstarize_toplevel "hmac_drbg_vectors_tmp" "hmac_drbg_vectors_low") /// HKDF /// https://tools.ietf.org/html/rfc5869.html /// pls extend me! We miss SHA2_384 and SHA2_512 tests /// /// The test is in 2 steps: /// prk <- extract sal ikm /// okm <- expand prk info okmlen noeq noextract type hkdf_vector = { ha: hash_alg; ikm: hex_encoded; // input key materials salt: hex_encoded; // input salt info: hex_encoded; // expansion label prk: hex_encoded; // extracted pseudo-random key (its length is Spec.Hash.Definitions.hash_len ha) okm: hex_encoded; // output: expanded key materials (its length is an input) } noextract let hkdf_vectors = [{ // Test Case 1 // Basic test case with SHA-256 ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h"000102030405060708090a0b0c";// (13 octets) info = h"f0f1f2f3f4f5f6f7f8f9";// (10 octets) prk = h"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5";// (32 octets) okm = h"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865";// (42 octets) }; { // Test Case 2 // Test with SHA-256 and longer inputs/outputs ha = SHA2_256; ikm = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f";// (80 octets) salt = h"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf";// (80 octets) info = h"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";// (80 octets) prk = h"06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244";// (32 octets) okm = h"b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87";// (82 octets) }; { // Test Case 3 // Test with SHA-256 and zero-length salt/info ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h""; info = h""; prk = h"19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04";// (32 octets) okm = h"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8";// (42 octets) }] noextract let hkdf_vectors_tmp = List.Tot.map (fun h -> h.ha, h.ikm, h.salt, h.info, h.prk, h.okm ) hkdf_vectors %splice[] (lowstarize_toplevel "hkdf_vectors_tmp" "hkdf_vectors_low") //TODO add test_hkdf, test_hkdf_one as for HMAC /// Cipher block function type block_cipher = | AES128 | AES256 // Funky field names to avoid collisions... noeq noextract type block_cipher_vector = { block: block_cipher; rkey: hex_encoded; plain: hex_encoded; enc: hex_encoded; } noextract let block_cipher_vectors = [ { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"3ad77bb40d7a3660a89ecaf32466ef97" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"f5d3d58503b9699de785895a96fdbaaf" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"43b1cd7f598ece23881b00e3ed030688" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"7b0c785e27e8ad3f8223207104725dd4" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"f3eed1bdb5d2a03c064b5a7e3db181f8" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"591ccb10d410ed26dc5ba74a31362870" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"b6ed21b99ca6f4f9f153e7b1beafed1d" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"23304b7a39f9f3ff067d8d8f9e24ecc7" }]
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "EverCrypt.Hash.fsti.checked" ], "interface_file": false, "source_file": "Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list (((Test.Vectors.block_cipher * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded)
Prims.Tot
[ "total" ]
[]
[ "FStar.List.Tot.Base.map", "Test.Vectors.block_cipher_vector", "FStar.Pervasives.Native.tuple4", "Test.Vectors.block_cipher", "Test.Lowstarize.hex_encoded", "FStar.Pervasives.Native.Mktuple4", "Test.Vectors.__proj__Mkblock_cipher_vector__item__block", "Test.Vectors.__proj__Mkblock_cipher_vector__item__rkey", "Test.Vectors.__proj__Mkblock_cipher_vector__item__plain", "Test.Vectors.__proj__Mkblock_cipher_vector__item__enc", "Test.Vectors.block_cipher_vectors" ]
[]
false
false
false
true
false
let block_cipher_vectors_tmp =
List.Tot.map (fun h -> h.block, h.rkey, h.plain, h.enc) block_cipher_vectors
false
Test.Vectors.fst
Test.Vectors.chacha20_vectors
val chacha20_vectors : Prims.list Test.Vectors.chacha20_vector
let chacha20_vectors = [ { c20_key = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"; c20_iv = h"000000000000004a00000000"; c20_ctr = 1ul; c20_plain = h"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e"; c20_cipher = h"6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d"; }]
{ "file_name": "providers/test/Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 349, "start_col": 0, "start_line": 342 }
module Test.Vectors open Test.Lowstarize open EverCrypt.Hash open Spec.Hash.Definitions /// Hash algorithms type hash_alg = EverCrypt.Hash.alg #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" noeq noextract type hash_vector = { (* The input [input] is repeated [repeat] times. *) hash_alg: hash_alg; input: string; output: hex_encoded; repeat: UInt32.t; } noextract let hash_vectors = [{ hash_alg = MD5; input = ""; output = h"d41d8cd98f00b204e9800998ecf8427e"; repeat = 1ul }; { hash_alg = MD5; input = "a"; output = h"0cc175b9c0f1b6a831c399e269772661"; repeat = 1ul }; { hash_alg = MD5; input = "abc"; output = h"900150983cd24fb0d6963f7d28e17f72"; repeat = 1ul }; { hash_alg = MD5; input = "message digest"; output = h"f96b697d7cb7938d525a2f31aaf161d0"; repeat = 1ul }; { hash_alg = MD5; input = "abcdefghijklmnopqrstuvwxyz"; output = h"c3fcd3d76192e4007dfb496cca67e13b"; repeat = 1ul }; { hash_alg = MD5; input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; output = h"d174ab98d277d9f5a5611c2c9f419d9f"; repeat = 1ul }; { hash_alg = MD5; input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; output = h"57edf4a22be3c955ac49da2e2107b67a"; repeat = 1ul }; { hash_alg = SHA1; input = "abc"; output = h"a9993e364706816aba3e25717850c26c9cd0d89d"; repeat = 1ul }; { hash_alg = SHA1; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"84983e441c3bd26ebaae4aa1f95129e5e54670f1"; repeat = 1ul }; { hash_alg = SHA1; input = "a"; output = h"34aa973cd4c4daa4f61eeb2bdbad27316534016f"; repeat = 1000000ul }; { hash_alg = SHA1; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"dea356a2cddd90c7a7ecedc5ebb563934f460452"; repeat = 10ul }; { hash_alg = SHA2_256; input = "abc"; output = h"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; repeat = 1ul }; { hash_alg = SHA2_256; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; repeat = 1ul }; { hash_alg = SHA2_256; input = "a"; output = h"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"; repeat = 1000000ul }; { hash_alg = SHA2_256; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5"; repeat = 10ul }; { hash_alg = SHA2_256; input = "\x19"; output = h"68aa2e2ee5dff96e3355e6c7ee373e3d6a4e17f75f9518d843709c0c9bc3e3d4"; repeat = 1ul };(* { hash_alg = SHA2_256; // 2018.05.26: Don't know how to encode byte literals in strings; this doesn't work // as in OCaml input = "\xe3\xd7\x25\x70\xdc\xdd\x78\x7c\xe3\x88\x7a\xb2\xcd\x68\x46\x52"; output = h"175ee69b02ba9b58e2b0a5fd13819cea573f3940a94f825128cf4209beabb4e8"; repeat = 1ul }; *){ hash_alg = SHA2_384; input = "abc"; output = h"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"; repeat = 1ul }; { hash_alg = SHA2_384; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"; repeat = 1ul }; { hash_alg = SHA2_384; input = "a"; output = h"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"; repeat = 1000000ul }; { hash_alg = SHA2_384; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"2fc64a4f500ddb6828f6a3430b8dd72a368eb7f3a8322a70bc84275b9c0b3ab00d27a5cc3c2d224aa6b61a0d79fb4596"; repeat = 10ul }; { hash_alg = SHA2_512; input = "abc"; output = h"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"; repeat = 1ul }; { hash_alg = SHA2_512; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"; repeat = 1ul }; { hash_alg = SHA2_512; input = "a"; output = h"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"; repeat = 1000000ul }; { hash_alg = SHA2_512; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"89d05ba632c699c31231ded4ffc127d5a894dad412c0e024db872d1abd2ba8141a0f85072a9be1e2aa04cf33c765cb510813a39cd5a84c4acaa64d3f3fb7bae9"; repeat = 10ul } ] noextract let hash_vectors_tmp = List.Tot.map (fun h -> h.hash_alg, h.input, h.output, h.repeat ) hash_vectors // 2018.08.06 SZ: I can't verify this in interactive mode but verifies from the command-line %splice[] (lowstarize_toplevel "hash_vectors_tmp" "hash_vectors_low") /// HMAC noeq noextract type hmac_vector = { ha: hash_alg; key: hex_encoded; data: hex_encoded; output: hex_encoded; } // selected test vectors from // https://tools.ietf.org/html/rfc4231#section-4.2 // pls extend me! noextract let hmac_vectors = [{ ha = SHA2_256; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"; }; { ha = SHA2_384; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6"; }] noextract let hmac_vectors_tmp = List.Tot.map (fun h -> h.ha, h.key, h.data, h.output ) hmac_vectors %splice[] (lowstarize_toplevel "hmac_vectors_tmp" "hmac_vectors_low") /// HMAC_DRBG noextract let hmac_drbg_vectors_tmp = let open Spec.HMAC_DRBG.Test.Vectors in List.Tot.map (fun x -> x.a, h x.entropy_input, h x.nonce, h x.personalization_string, h x.entropy_input_reseed, h x.additional_input_reseed, (h x.additional_input_1, h x.additional_input_2), h x.returned_bits) test_vectors %splice[] (lowstarize_toplevel "hmac_drbg_vectors_tmp" "hmac_drbg_vectors_low") /// HKDF /// https://tools.ietf.org/html/rfc5869.html /// pls extend me! We miss SHA2_384 and SHA2_512 tests /// /// The test is in 2 steps: /// prk <- extract sal ikm /// okm <- expand prk info okmlen noeq noextract type hkdf_vector = { ha: hash_alg; ikm: hex_encoded; // input key materials salt: hex_encoded; // input salt info: hex_encoded; // expansion label prk: hex_encoded; // extracted pseudo-random key (its length is Spec.Hash.Definitions.hash_len ha) okm: hex_encoded; // output: expanded key materials (its length is an input) } noextract let hkdf_vectors = [{ // Test Case 1 // Basic test case with SHA-256 ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h"000102030405060708090a0b0c";// (13 octets) info = h"f0f1f2f3f4f5f6f7f8f9";// (10 octets) prk = h"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5";// (32 octets) okm = h"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865";// (42 octets) }; { // Test Case 2 // Test with SHA-256 and longer inputs/outputs ha = SHA2_256; ikm = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f";// (80 octets) salt = h"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf";// (80 octets) info = h"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";// (80 octets) prk = h"06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244";// (32 octets) okm = h"b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87";// (82 octets) }; { // Test Case 3 // Test with SHA-256 and zero-length salt/info ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h""; info = h""; prk = h"19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04";// (32 octets) okm = h"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8";// (42 octets) }] noextract let hkdf_vectors_tmp = List.Tot.map (fun h -> h.ha, h.ikm, h.salt, h.info, h.prk, h.okm ) hkdf_vectors %splice[] (lowstarize_toplevel "hkdf_vectors_tmp" "hkdf_vectors_low") //TODO add test_hkdf, test_hkdf_one as for HMAC /// Cipher block function type block_cipher = | AES128 | AES256 // Funky field names to avoid collisions... noeq noextract type block_cipher_vector = { block: block_cipher; rkey: hex_encoded; plain: hex_encoded; enc: hex_encoded; } noextract let block_cipher_vectors = [ { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"3ad77bb40d7a3660a89ecaf32466ef97" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"f5d3d58503b9699de785895a96fdbaaf" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"43b1cd7f598ece23881b00e3ed030688" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"7b0c785e27e8ad3f8223207104725dd4" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"f3eed1bdb5d2a03c064b5a7e3db181f8" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"591ccb10d410ed26dc5ba74a31362870" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"b6ed21b99ca6f4f9f153e7b1beafed1d" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"23304b7a39f9f3ff067d8d8f9e24ecc7" }] noextract let block_cipher_vectors_tmp = List.Tot.map (fun h -> h.block, h.rkey, h.plain, h.enc ) block_cipher_vectors %splice[] (lowstarize_toplevel "block_cipher_vectors_tmp" "block_cipher_vectors_low") noeq noextract type chacha20_vector = { c20_key: hex_encoded; c20_iv: hex_encoded; c20_ctr: UInt32.t; c20_plain: hex_encoded; c20_cipher: hex_encoded; }
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "EverCrypt.Hash.fsti.checked" ], "interface_file": false, "source_file": "Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Test.Vectors.chacha20_vector
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "Test.Vectors.chacha20_vector", "Test.Vectors.Mkchacha20_vector", "Test.Lowstarize.h", "FStar.UInt32.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
true
false
let chacha20_vectors =
[ { c20_key = h "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"; c20_iv = h "000000000000004a00000000"; c20_ctr = 1ul; c20_plain = h "4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e" ; c20_cipher = h "6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d" } ]
false
Test.Vectors.fst
Test.Vectors.chacha20_vectors_tmp
val chacha20_vectors_tmp : Prims.list ((((Test.Lowstarize.hex_encoded * Test.Lowstarize.hex_encoded) * FStar.UInt32.t) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded)
let chacha20_vectors_tmp = List.Tot.map (fun h -> h.c20_key, h.c20_iv, h.c20_ctr, h.c20_plain, h.c20_cipher ) chacha20_vectors
{ "file_name": "providers/test/Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 354, "start_col": 0, "start_line": 352 }
module Test.Vectors open Test.Lowstarize open EverCrypt.Hash open Spec.Hash.Definitions /// Hash algorithms type hash_alg = EverCrypt.Hash.alg #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" noeq noextract type hash_vector = { (* The input [input] is repeated [repeat] times. *) hash_alg: hash_alg; input: string; output: hex_encoded; repeat: UInt32.t; } noextract let hash_vectors = [{ hash_alg = MD5; input = ""; output = h"d41d8cd98f00b204e9800998ecf8427e"; repeat = 1ul }; { hash_alg = MD5; input = "a"; output = h"0cc175b9c0f1b6a831c399e269772661"; repeat = 1ul }; { hash_alg = MD5; input = "abc"; output = h"900150983cd24fb0d6963f7d28e17f72"; repeat = 1ul }; { hash_alg = MD5; input = "message digest"; output = h"f96b697d7cb7938d525a2f31aaf161d0"; repeat = 1ul }; { hash_alg = MD5; input = "abcdefghijklmnopqrstuvwxyz"; output = h"c3fcd3d76192e4007dfb496cca67e13b"; repeat = 1ul }; { hash_alg = MD5; input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; output = h"d174ab98d277d9f5a5611c2c9f419d9f"; repeat = 1ul }; { hash_alg = MD5; input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; output = h"57edf4a22be3c955ac49da2e2107b67a"; repeat = 1ul }; { hash_alg = SHA1; input = "abc"; output = h"a9993e364706816aba3e25717850c26c9cd0d89d"; repeat = 1ul }; { hash_alg = SHA1; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"84983e441c3bd26ebaae4aa1f95129e5e54670f1"; repeat = 1ul }; { hash_alg = SHA1; input = "a"; output = h"34aa973cd4c4daa4f61eeb2bdbad27316534016f"; repeat = 1000000ul }; { hash_alg = SHA1; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"dea356a2cddd90c7a7ecedc5ebb563934f460452"; repeat = 10ul }; { hash_alg = SHA2_256; input = "abc"; output = h"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; repeat = 1ul }; { hash_alg = SHA2_256; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; repeat = 1ul }; { hash_alg = SHA2_256; input = "a"; output = h"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"; repeat = 1000000ul }; { hash_alg = SHA2_256; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5"; repeat = 10ul }; { hash_alg = SHA2_256; input = "\x19"; output = h"68aa2e2ee5dff96e3355e6c7ee373e3d6a4e17f75f9518d843709c0c9bc3e3d4"; repeat = 1ul };(* { hash_alg = SHA2_256; // 2018.05.26: Don't know how to encode byte literals in strings; this doesn't work // as in OCaml input = "\xe3\xd7\x25\x70\xdc\xdd\x78\x7c\xe3\x88\x7a\xb2\xcd\x68\x46\x52"; output = h"175ee69b02ba9b58e2b0a5fd13819cea573f3940a94f825128cf4209beabb4e8"; repeat = 1ul }; *){ hash_alg = SHA2_384; input = "abc"; output = h"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"; repeat = 1ul }; { hash_alg = SHA2_384; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"; repeat = 1ul }; { hash_alg = SHA2_384; input = "a"; output = h"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"; repeat = 1000000ul }; { hash_alg = SHA2_384; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"2fc64a4f500ddb6828f6a3430b8dd72a368eb7f3a8322a70bc84275b9c0b3ab00d27a5cc3c2d224aa6b61a0d79fb4596"; repeat = 10ul }; { hash_alg = SHA2_512; input = "abc"; output = h"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"; repeat = 1ul }; { hash_alg = SHA2_512; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"; repeat = 1ul }; { hash_alg = SHA2_512; input = "a"; output = h"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"; repeat = 1000000ul }; { hash_alg = SHA2_512; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"89d05ba632c699c31231ded4ffc127d5a894dad412c0e024db872d1abd2ba8141a0f85072a9be1e2aa04cf33c765cb510813a39cd5a84c4acaa64d3f3fb7bae9"; repeat = 10ul } ] noextract let hash_vectors_tmp = List.Tot.map (fun h -> h.hash_alg, h.input, h.output, h.repeat ) hash_vectors // 2018.08.06 SZ: I can't verify this in interactive mode but verifies from the command-line %splice[] (lowstarize_toplevel "hash_vectors_tmp" "hash_vectors_low") /// HMAC noeq noextract type hmac_vector = { ha: hash_alg; key: hex_encoded; data: hex_encoded; output: hex_encoded; } // selected test vectors from // https://tools.ietf.org/html/rfc4231#section-4.2 // pls extend me! noextract let hmac_vectors = [{ ha = SHA2_256; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"; }; { ha = SHA2_384; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6"; }] noextract let hmac_vectors_tmp = List.Tot.map (fun h -> h.ha, h.key, h.data, h.output ) hmac_vectors %splice[] (lowstarize_toplevel "hmac_vectors_tmp" "hmac_vectors_low") /// HMAC_DRBG noextract let hmac_drbg_vectors_tmp = let open Spec.HMAC_DRBG.Test.Vectors in List.Tot.map (fun x -> x.a, h x.entropy_input, h x.nonce, h x.personalization_string, h x.entropy_input_reseed, h x.additional_input_reseed, (h x.additional_input_1, h x.additional_input_2), h x.returned_bits) test_vectors %splice[] (lowstarize_toplevel "hmac_drbg_vectors_tmp" "hmac_drbg_vectors_low") /// HKDF /// https://tools.ietf.org/html/rfc5869.html /// pls extend me! We miss SHA2_384 and SHA2_512 tests /// /// The test is in 2 steps: /// prk <- extract sal ikm /// okm <- expand prk info okmlen noeq noextract type hkdf_vector = { ha: hash_alg; ikm: hex_encoded; // input key materials salt: hex_encoded; // input salt info: hex_encoded; // expansion label prk: hex_encoded; // extracted pseudo-random key (its length is Spec.Hash.Definitions.hash_len ha) okm: hex_encoded; // output: expanded key materials (its length is an input) } noextract let hkdf_vectors = [{ // Test Case 1 // Basic test case with SHA-256 ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h"000102030405060708090a0b0c";// (13 octets) info = h"f0f1f2f3f4f5f6f7f8f9";// (10 octets) prk = h"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5";// (32 octets) okm = h"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865";// (42 octets) }; { // Test Case 2 // Test with SHA-256 and longer inputs/outputs ha = SHA2_256; ikm = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f";// (80 octets) salt = h"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf";// (80 octets) info = h"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";// (80 octets) prk = h"06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244";// (32 octets) okm = h"b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87";// (82 octets) }; { // Test Case 3 // Test with SHA-256 and zero-length salt/info ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h""; info = h""; prk = h"19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04";// (32 octets) okm = h"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8";// (42 octets) }] noextract let hkdf_vectors_tmp = List.Tot.map (fun h -> h.ha, h.ikm, h.salt, h.info, h.prk, h.okm ) hkdf_vectors %splice[] (lowstarize_toplevel "hkdf_vectors_tmp" "hkdf_vectors_low") //TODO add test_hkdf, test_hkdf_one as for HMAC /// Cipher block function type block_cipher = | AES128 | AES256 // Funky field names to avoid collisions... noeq noextract type block_cipher_vector = { block: block_cipher; rkey: hex_encoded; plain: hex_encoded; enc: hex_encoded; } noextract let block_cipher_vectors = [ { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"3ad77bb40d7a3660a89ecaf32466ef97" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"f5d3d58503b9699de785895a96fdbaaf" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"43b1cd7f598ece23881b00e3ed030688" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"7b0c785e27e8ad3f8223207104725dd4" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"f3eed1bdb5d2a03c064b5a7e3db181f8" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"591ccb10d410ed26dc5ba74a31362870" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"b6ed21b99ca6f4f9f153e7b1beafed1d" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"23304b7a39f9f3ff067d8d8f9e24ecc7" }] noextract let block_cipher_vectors_tmp = List.Tot.map (fun h -> h.block, h.rkey, h.plain, h.enc ) block_cipher_vectors %splice[] (lowstarize_toplevel "block_cipher_vectors_tmp" "block_cipher_vectors_low") noeq noextract type chacha20_vector = { c20_key: hex_encoded; c20_iv: hex_encoded; c20_ctr: UInt32.t; c20_plain: hex_encoded; c20_cipher: hex_encoded; } noextract let chacha20_vectors = [ { c20_key = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"; c20_iv = h"000000000000004a00000000"; c20_ctr = 1ul; c20_plain = h"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e"; c20_cipher = h"6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d"; }]
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "EverCrypt.Hash.fsti.checked" ], "interface_file": false, "source_file": "Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list ((((Test.Lowstarize.hex_encoded * Test.Lowstarize.hex_encoded) * FStar.UInt32.t) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded)
Prims.Tot
[ "total" ]
[]
[ "FStar.List.Tot.Base.map", "Test.Vectors.chacha20_vector", "FStar.Pervasives.Native.tuple5", "Test.Lowstarize.hex_encoded", "FStar.UInt32.t", "FStar.Pervasives.Native.Mktuple5", "Test.Vectors.__proj__Mkchacha20_vector__item__c20_key", "Test.Vectors.__proj__Mkchacha20_vector__item__c20_iv", "Test.Vectors.__proj__Mkchacha20_vector__item__c20_ctr", "Test.Vectors.__proj__Mkchacha20_vector__item__c20_plain", "Test.Vectors.__proj__Mkchacha20_vector__item__c20_cipher", "Test.Vectors.chacha20_vectors" ]
[]
false
false
false
true
false
let chacha20_vectors_tmp =
List.Tot.map (fun h -> h.c20_key, h.c20_iv, h.c20_ctr, h.c20_plain, h.c20_cipher) chacha20_vectors
false
Hacl.Impl.SHA2.Core.fst
Hacl.Impl.SHA2.Core.get_multilast
val get_multilast: #a:sha2_alg -> #m:m_spec{is_supported a m} -> get_multilast_t a m
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 = 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
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Core.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 892, "start_col": 0, "start_line": 856 }
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
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
Hacl.Impl.SHA2.Core.get_multilast_t a m
Prims.Tot
[ "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" ]
[]
false
false
false
false
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
false
Test.Vectors.fst
Test.Vectors.aead_vectors
val aead_vectors : Prims.list Test.Vectors.aead_vector
let aead_vectors = [ { (* rfc7539#page-22 *) cipher = CHACHA20_POLY1305; key = h"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f"; iv = h"070000004041424344454647"; aad = h"50515253c0c1c2c3c4c5c6c7"; tag = h"1ae10b594f09e26a7e902ecbd0600691"; plaintext = h"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e"; ciphertext = h"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116"; }; { cipher = CHACHA20_POLY1305; key = h"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0"; iv = h"000000000102030405060708"; aad = h"f33388860000000000004e91"; tag = h"eead9d67890cbb22392336fea1851f38"; plaintext = h"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d"; ciphertext = h"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"58e2fccefa7e3061367f1d57a4e7455a"; plaintext = h""; ciphertext = h""; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"ab6e47d42cec13bdf53a67b21257bddf"; plaintext = h"00000000000000000000000000000000"; ciphertext = h"0388dace60b6a392f328c2b971b2fe78"; }; { cipher = AES_128_GCM; key = h"feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbaddecaf888"; aad = h""; tag = h"4d5c2af327cd64a62cf35abd2ba6fab4"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255"; ciphertext = h"42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985"; }; { cipher = AES_128_GCM; key = h"feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbaddecaf888"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"5bc94fbc3221a5db94fae95ae7121a47"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091"; }; { cipher = AES_128_GCM; key = h"feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbad"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"3612d2e79e3b0785561be14aaca2fccb"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c742373806900e49f24b22b097544d4896b424989b5e1ebac0f07c23f4598"; }; { cipher = AES_128_GCM; key = h"feffe9928665731c6d6a8f9467308308"; iv = h"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"619cc5aefffe0bfa462af43c1699d050"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca701e4a9a4fba43c90ccdcb281d48c7c6fd62875d2aca417034c34aee5"; }; { cipher = AES_256_GCM; key = h"0000000000000000000000000000000000000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"530f8afbc74536b9a963b4f1c4cb738b"; plaintext = h""; ciphertext = h""; }; { cipher = AES_256_GCM; key = h"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbaddecaf888"; aad = h""; tag = h"b094dac5d93471bdec1a502270e3cc6c"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255"; ciphertext = h"522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad"; }; { cipher = AES_256_GCM; key = h"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbaddecaf888"; aad = h""; tag = h"b094dac5d93471bdec1a502270e3cc6c"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255"; ciphertext = h"522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad"; }; { cipher = AES_256_GCM; key = h"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbaddecaf888"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"76fc6ece0f4e1768cddf8853bb2d551b"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662"; }; { cipher = AES_256_GCM; key = h"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbad"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"3a337dbf46a792c45e454913fe2ea8f2"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0feb582d33934a4f0954cc2363bc73f7862ac430e64abe499f47c9b1f"; }; { cipher = AES_256_GCM; key = h"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"a44a8266ee1c8eb0c8b5d4cf5ae9f19a"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad"; tag = h"5fea793a2d6f974d37e68e0cb8ff9492"; plaintext = h""; ciphertext = h""; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"9dd0a376b08e40eb00c35f29f9ea61a4"; plaintext = h"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ciphertext = h"0388dace60b6a392f328c2b971b2fe78f795aaab494b5923f7fd89ff948bc1e0200211214e7394da2089b6acd093abe0"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"98885a3a22bd4742fe7b72172193b163"; plaintext = h"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ciphertext = h"0388dace60b6a392f328c2b971b2fe78f795aaab494b5923f7fd89ff948bc1e0200211214e7394da2089b6acd093abe0c94da219118e297d7b7ebcbcc9c388f28ade7d85a8ee35616f7124a9d5270291"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"cac45f60e31efd3b5a43b98a22ce1aa1"; plaintext = h"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ciphertext = h"0388dace60b6a392f328c2b971b2fe78f795aaab494b5923f7fd89ff948bc1e0200211214e7394da2089b6acd093abe0c94da219118e297d7b7ebcbcc9c388f28ade7d85a8ee35616f7124a9d527029195b84d1b96c690ff2f2de30bf2ec89e00253786e126504f0dab90c48a30321de3345e6b0461e7c9e6c6b7afedde83f40"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"ffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; aad = h""; tag = h"566f8ef683078bfdeeffa869d751a017"; plaintext = h"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ciphertext = h"56b3373ca9ef6e4a2b64fe1e9a17b61425f10d47a75a5fce13efc6bc784af24f4141bdd48cf7c770887afd573cca5418a9aeffcd7c5ceddfc6a78397b9a85b499da558257267caab2ad0b23ca476a53cb17fb41c4b8b475cb4f3f7165094c229c9e8c4dc0a2a5ff1903e501511221376a1cdb8364c5061a20cae74bc4acd76ceb0abc9fd3217ef9f8c90be402ddf6d8697f4f880dff15bfb7a6b28241ec8fe183c2d59e3f9dfff653c7126f0acb9e64211f42bae12af462b1070bef1ab5e3606"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"ffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; aad = h""; tag = h"8b307f6b33286d0ab026a9ed3fe1e85f"; plaintext = h"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ciphertext = h"56b3373ca9ef6e4a2b64fe1e9a17b61425f10d47a75a5fce13efc6bc784af24f4141bdd48cf7c770887afd573cca5418a9aeffcd7c5ceddfc6a78397b9a85b499da558257267caab2ad0b23ca476a53cb17fb41c4b8b475cb4f3f7165094c229c9e8c4dc0a2a5ff1903e501511221376a1cdb8364c5061a20cae74bc4acd76ceb0abc9fd3217ef9f8c90be402ddf6d8697f4f880dff15bfb7a6b28241ec8fe183c2d59e3f9dfff653c7126f0acb9e64211f42bae12af462b1070bef1ab5e3606872ca10dee15b3249b1a1b958f23134c4bccb7d03200bce420a2f8eb66dcf3644d1423c1b5699003c13ecef4bf38a3b60eedc34033bac1902783dc6d89e2e774188a439c7ebcc0672dbda4ddcfb2794613b0be41315ef778708a70ee7d75165c"; }; { cipher = AES_128_GCM; key = h"843ffcf5d2b72694d19ed01d01249412"; iv = h"dbcca32ebf9b804617c3aa9e"; aad = h"00000000000000000000000000000000101112131415161718191a1b1c1d1e1f"; tag = h"3b629ccfbc1119b7319e1dce2cd6fd6d"; plaintext = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f"; ciphertext = h"6268c6fa2a80b2d137467f092f657ac04d89be2beaa623d61b5a868c8f03ff95d3dcee23ad2f1ab3a6c80eaf4b140eb05de3457f0fbc111a6b43d0763aa422a3013cf1dc37fe417d1fbfc449b75d4cc5"; }; ]
{ "file_name": "providers/test/Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 1, "end_line": 567, "start_col": 0, "start_line": 377 }
module Test.Vectors open Test.Lowstarize open EverCrypt.Hash open Spec.Hash.Definitions /// Hash algorithms type hash_alg = EverCrypt.Hash.alg #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" noeq noextract type hash_vector = { (* The input [input] is repeated [repeat] times. *) hash_alg: hash_alg; input: string; output: hex_encoded; repeat: UInt32.t; } noextract let hash_vectors = [{ hash_alg = MD5; input = ""; output = h"d41d8cd98f00b204e9800998ecf8427e"; repeat = 1ul }; { hash_alg = MD5; input = "a"; output = h"0cc175b9c0f1b6a831c399e269772661"; repeat = 1ul }; { hash_alg = MD5; input = "abc"; output = h"900150983cd24fb0d6963f7d28e17f72"; repeat = 1ul }; { hash_alg = MD5; input = "message digest"; output = h"f96b697d7cb7938d525a2f31aaf161d0"; repeat = 1ul }; { hash_alg = MD5; input = "abcdefghijklmnopqrstuvwxyz"; output = h"c3fcd3d76192e4007dfb496cca67e13b"; repeat = 1ul }; { hash_alg = MD5; input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; output = h"d174ab98d277d9f5a5611c2c9f419d9f"; repeat = 1ul }; { hash_alg = MD5; input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; output = h"57edf4a22be3c955ac49da2e2107b67a"; repeat = 1ul }; { hash_alg = SHA1; input = "abc"; output = h"a9993e364706816aba3e25717850c26c9cd0d89d"; repeat = 1ul }; { hash_alg = SHA1; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"84983e441c3bd26ebaae4aa1f95129e5e54670f1"; repeat = 1ul }; { hash_alg = SHA1; input = "a"; output = h"34aa973cd4c4daa4f61eeb2bdbad27316534016f"; repeat = 1000000ul }; { hash_alg = SHA1; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"dea356a2cddd90c7a7ecedc5ebb563934f460452"; repeat = 10ul }; { hash_alg = SHA2_256; input = "abc"; output = h"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; repeat = 1ul }; { hash_alg = SHA2_256; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; repeat = 1ul }; { hash_alg = SHA2_256; input = "a"; output = h"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"; repeat = 1000000ul }; { hash_alg = SHA2_256; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5"; repeat = 10ul }; { hash_alg = SHA2_256; input = "\x19"; output = h"68aa2e2ee5dff96e3355e6c7ee373e3d6a4e17f75f9518d843709c0c9bc3e3d4"; repeat = 1ul };(* { hash_alg = SHA2_256; // 2018.05.26: Don't know how to encode byte literals in strings; this doesn't work // as in OCaml input = "\xe3\xd7\x25\x70\xdc\xdd\x78\x7c\xe3\x88\x7a\xb2\xcd\x68\x46\x52"; output = h"175ee69b02ba9b58e2b0a5fd13819cea573f3940a94f825128cf4209beabb4e8"; repeat = 1ul }; *){ hash_alg = SHA2_384; input = "abc"; output = h"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"; repeat = 1ul }; { hash_alg = SHA2_384; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"; repeat = 1ul }; { hash_alg = SHA2_384; input = "a"; output = h"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"; repeat = 1000000ul }; { hash_alg = SHA2_384; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"2fc64a4f500ddb6828f6a3430b8dd72a368eb7f3a8322a70bc84275b9c0b3ab00d27a5cc3c2d224aa6b61a0d79fb4596"; repeat = 10ul }; { hash_alg = SHA2_512; input = "abc"; output = h"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"; repeat = 1ul }; { hash_alg = SHA2_512; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"; repeat = 1ul }; { hash_alg = SHA2_512; input = "a"; output = h"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"; repeat = 1000000ul }; { hash_alg = SHA2_512; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"89d05ba632c699c31231ded4ffc127d5a894dad412c0e024db872d1abd2ba8141a0f85072a9be1e2aa04cf33c765cb510813a39cd5a84c4acaa64d3f3fb7bae9"; repeat = 10ul } ] noextract let hash_vectors_tmp = List.Tot.map (fun h -> h.hash_alg, h.input, h.output, h.repeat ) hash_vectors // 2018.08.06 SZ: I can't verify this in interactive mode but verifies from the command-line %splice[] (lowstarize_toplevel "hash_vectors_tmp" "hash_vectors_low") /// HMAC noeq noextract type hmac_vector = { ha: hash_alg; key: hex_encoded; data: hex_encoded; output: hex_encoded; } // selected test vectors from // https://tools.ietf.org/html/rfc4231#section-4.2 // pls extend me! noextract let hmac_vectors = [{ ha = SHA2_256; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"; }; { ha = SHA2_384; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6"; }] noextract let hmac_vectors_tmp = List.Tot.map (fun h -> h.ha, h.key, h.data, h.output ) hmac_vectors %splice[] (lowstarize_toplevel "hmac_vectors_tmp" "hmac_vectors_low") /// HMAC_DRBG noextract let hmac_drbg_vectors_tmp = let open Spec.HMAC_DRBG.Test.Vectors in List.Tot.map (fun x -> x.a, h x.entropy_input, h x.nonce, h x.personalization_string, h x.entropy_input_reseed, h x.additional_input_reseed, (h x.additional_input_1, h x.additional_input_2), h x.returned_bits) test_vectors %splice[] (lowstarize_toplevel "hmac_drbg_vectors_tmp" "hmac_drbg_vectors_low") /// HKDF /// https://tools.ietf.org/html/rfc5869.html /// pls extend me! We miss SHA2_384 and SHA2_512 tests /// /// The test is in 2 steps: /// prk <- extract sal ikm /// okm <- expand prk info okmlen noeq noextract type hkdf_vector = { ha: hash_alg; ikm: hex_encoded; // input key materials salt: hex_encoded; // input salt info: hex_encoded; // expansion label prk: hex_encoded; // extracted pseudo-random key (its length is Spec.Hash.Definitions.hash_len ha) okm: hex_encoded; // output: expanded key materials (its length is an input) } noextract let hkdf_vectors = [{ // Test Case 1 // Basic test case with SHA-256 ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h"000102030405060708090a0b0c";// (13 octets) info = h"f0f1f2f3f4f5f6f7f8f9";// (10 octets) prk = h"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5";// (32 octets) okm = h"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865";// (42 octets) }; { // Test Case 2 // Test with SHA-256 and longer inputs/outputs ha = SHA2_256; ikm = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f";// (80 octets) salt = h"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf";// (80 octets) info = h"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";// (80 octets) prk = h"06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244";// (32 octets) okm = h"b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87";// (82 octets) }; { // Test Case 3 // Test with SHA-256 and zero-length salt/info ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h""; info = h""; prk = h"19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04";// (32 octets) okm = h"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8";// (42 octets) }] noextract let hkdf_vectors_tmp = List.Tot.map (fun h -> h.ha, h.ikm, h.salt, h.info, h.prk, h.okm ) hkdf_vectors %splice[] (lowstarize_toplevel "hkdf_vectors_tmp" "hkdf_vectors_low") //TODO add test_hkdf, test_hkdf_one as for HMAC /// Cipher block function type block_cipher = | AES128 | AES256 // Funky field names to avoid collisions... noeq noextract type block_cipher_vector = { block: block_cipher; rkey: hex_encoded; plain: hex_encoded; enc: hex_encoded; } noextract let block_cipher_vectors = [ { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"3ad77bb40d7a3660a89ecaf32466ef97" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"f5d3d58503b9699de785895a96fdbaaf" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"43b1cd7f598ece23881b00e3ed030688" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"7b0c785e27e8ad3f8223207104725dd4" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"f3eed1bdb5d2a03c064b5a7e3db181f8" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"591ccb10d410ed26dc5ba74a31362870" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"b6ed21b99ca6f4f9f153e7b1beafed1d" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"23304b7a39f9f3ff067d8d8f9e24ecc7" }] noextract let block_cipher_vectors_tmp = List.Tot.map (fun h -> h.block, h.rkey, h.plain, h.enc ) block_cipher_vectors %splice[] (lowstarize_toplevel "block_cipher_vectors_tmp" "block_cipher_vectors_low") noeq noextract type chacha20_vector = { c20_key: hex_encoded; c20_iv: hex_encoded; c20_ctr: UInt32.t; c20_plain: hex_encoded; c20_cipher: hex_encoded; } noextract let chacha20_vectors = [ { c20_key = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"; c20_iv = h"000000000000004a00000000"; c20_ctr = 1ul; c20_plain = h"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e"; c20_cipher = h"6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d"; }] noextract let chacha20_vectors_tmp = List.Tot.map (fun h -> h.c20_key, h.c20_iv, h.c20_ctr, h.c20_plain, h.c20_cipher ) chacha20_vectors %splice[] (lowstarize_toplevel "chacha20_vectors_tmp" "chacha20_vectors_low") /// AEAD type cipher = | AES_128_GCM | AES_256_GCM | CHACHA20_POLY1305 noeq noextract type aead_vector = { cipher: cipher; key: hex_encoded; iv : hex_encoded; aad: hex_encoded; tag: hex_encoded; plaintext: hex_encoded; ciphertext: hex_encoded; }
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "EverCrypt.Hash.fsti.checked" ], "interface_file": false, "source_file": "Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Test.Vectors.aead_vector
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "Test.Vectors.aead_vector", "Test.Vectors.Mkaead_vector", "Test.Vectors.CHACHA20_POLY1305", "Test.Lowstarize.h", "Test.Vectors.AES_128_GCM", "Test.Vectors.AES_256_GCM", "Prims.Nil" ]
[]
false
false
false
true
false
let aead_vectors =
[ { cipher = CHACHA20_POLY1305; key = h "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f"; iv = h "070000004041424344454647"; aad = h "50515253c0c1c2c3c4c5c6c7"; tag = h "1ae10b594f09e26a7e902ecbd0600691"; plaintext = h "4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e" ; ciphertext = h "d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116" }; { cipher = CHACHA20_POLY1305; key = h "1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0"; iv = h "000000000102030405060708"; aad = h "f33388860000000000004e91"; tag = h "eead9d67890cbb22392336fea1851f38"; plaintext = h "496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d" ; ciphertext = h "64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b" }; { cipher = AES_128_GCM; key = h "00000000000000000000000000000000"; iv = h "000000000000000000000000"; aad = h ""; tag = h "58e2fccefa7e3061367f1d57a4e7455a"; plaintext = h ""; ciphertext = h "" }; { cipher = AES_128_GCM; key = h "00000000000000000000000000000000"; iv = h "000000000000000000000000"; aad = h ""; tag = h "ab6e47d42cec13bdf53a67b21257bddf"; plaintext = h "00000000000000000000000000000000"; ciphertext = h "0388dace60b6a392f328c2b971b2fe78" }; { cipher = AES_128_GCM; key = h "feffe9928665731c6d6a8f9467308308"; iv = h "cafebabefacedbaddecaf888"; aad = h ""; tag = h "4d5c2af327cd64a62cf35abd2ba6fab4"; plaintext = h "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255" ; ciphertext = h "42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985" }; { cipher = AES_128_GCM; key = h "feffe9928665731c6d6a8f9467308308"; iv = h "cafebabefacedbaddecaf888"; aad = h "feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h "5bc94fbc3221a5db94fae95ae7121a47"; plaintext = h "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39" ; ciphertext = h "42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091" }; { cipher = AES_128_GCM; key = h "feffe9928665731c6d6a8f9467308308"; iv = h "cafebabefacedbad"; aad = h "feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h "3612d2e79e3b0785561be14aaca2fccb"; plaintext = h "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39" ; ciphertext = h "61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c742373806900e49f24b22b097544d4896b424989b5e1ebac0f07c23f4598" }; { cipher = AES_128_GCM; key = h "feffe9928665731c6d6a8f9467308308"; iv = h "9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b" ; aad = h "feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h "619cc5aefffe0bfa462af43c1699d050"; plaintext = h "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39" ; ciphertext = h "8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca701e4a9a4fba43c90ccdcb281d48c7c6fd62875d2aca417034c34aee5" }; { cipher = AES_256_GCM; key = h "0000000000000000000000000000000000000000000000000000000000000000"; iv = h "000000000000000000000000"; aad = h ""; tag = h "530f8afbc74536b9a963b4f1c4cb738b"; plaintext = h ""; ciphertext = h "" }; { cipher = AES_256_GCM; key = h "feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h "cafebabefacedbaddecaf888"; aad = h ""; tag = h "b094dac5d93471bdec1a502270e3cc6c"; plaintext = h "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255" ; ciphertext = h "522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad" }; { cipher = AES_256_GCM; key = h "feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h "cafebabefacedbaddecaf888"; aad = h ""; tag = h "b094dac5d93471bdec1a502270e3cc6c"; plaintext = h "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255" ; ciphertext = h "522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad" }; { cipher = AES_256_GCM; key = h "feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h "cafebabefacedbaddecaf888"; aad = h "feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h "76fc6ece0f4e1768cddf8853bb2d551b"; plaintext = h "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39" ; ciphertext = h "522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662" }; { cipher = AES_256_GCM; key = h "feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h "cafebabefacedbad"; aad = h "feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h "3a337dbf46a792c45e454913fe2ea8f2"; plaintext = h "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39" ; ciphertext = h "c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0feb582d33934a4f0954cc2363bc73f7862ac430e64abe499f47c9b1f" }; { cipher = AES_256_GCM; key = h "feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h "9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b" ; aad = h "feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h "a44a8266ee1c8eb0c8b5d4cf5ae9f19a"; plaintext = h "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39" ; ciphertext = h "5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f" }; { cipher = AES_128_GCM; key = h "00000000000000000000000000000000"; iv = h "000000000000000000000000"; aad = h "d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad" ; tag = h "5fea793a2d6f974d37e68e0cb8ff9492"; plaintext = h ""; ciphertext = h "" }; { cipher = AES_128_GCM; key = h "00000000000000000000000000000000"; iv = h "000000000000000000000000"; aad = h ""; tag = h "9dd0a376b08e40eb00c35f29f9ea61a4"; plaintext = h "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ; ciphertext = h "0388dace60b6a392f328c2b971b2fe78f795aaab494b5923f7fd89ff948bc1e0200211214e7394da2089b6acd093abe0" }; { cipher = AES_128_GCM; key = h "00000000000000000000000000000000"; iv = h "000000000000000000000000"; aad = h ""; tag = h "98885a3a22bd4742fe7b72172193b163"; plaintext = h "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ; ciphertext = h "0388dace60b6a392f328c2b971b2fe78f795aaab494b5923f7fd89ff948bc1e0200211214e7394da2089b6acd093abe0c94da219118e297d7b7ebcbcc9c388f28ade7d85a8ee35616f7124a9d5270291" }; { cipher = AES_128_GCM; key = h "00000000000000000000000000000000"; iv = h "000000000000000000000000"; aad = h ""; tag = h "cac45f60e31efd3b5a43b98a22ce1aa1"; plaintext = h "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ; ciphertext = h "0388dace60b6a392f328c2b971b2fe78f795aaab494b5923f7fd89ff948bc1e0200211214e7394da2089b6acd093abe0c94da219118e297d7b7ebcbcc9c388f28ade7d85a8ee35616f7124a9d527029195b84d1b96c690ff2f2de30bf2ec89e00253786e126504f0dab90c48a30321de3345e6b0461e7c9e6c6b7afedde83f40" }; { cipher = AES_128_GCM; key = h "00000000000000000000000000000000"; iv = h "ffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ; aad = h ""; tag = h "566f8ef683078bfdeeffa869d751a017"; plaintext = h "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ; ciphertext = h "56b3373ca9ef6e4a2b64fe1e9a17b61425f10d47a75a5fce13efc6bc784af24f4141bdd48cf7c770887afd573cca5418a9aeffcd7c5ceddfc6a78397b9a85b499da558257267caab2ad0b23ca476a53cb17fb41c4b8b475cb4f3f7165094c229c9e8c4dc0a2a5ff1903e501511221376a1cdb8364c5061a20cae74bc4acd76ceb0abc9fd3217ef9f8c90be402ddf6d8697f4f880dff15bfb7a6b28241ec8fe183c2d59e3f9dfff653c7126f0acb9e64211f42bae12af462b1070bef1ab5e3606" }; { cipher = AES_128_GCM; key = h "00000000000000000000000000000000"; iv = h "ffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ; aad = h ""; tag = h "8b307f6b33286d0ab026a9ed3fe1e85f"; plaintext = h "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ; ciphertext = h "56b3373ca9ef6e4a2b64fe1e9a17b61425f10d47a75a5fce13efc6bc784af24f4141bdd48cf7c770887afd573cca5418a9aeffcd7c5ceddfc6a78397b9a85b499da558257267caab2ad0b23ca476a53cb17fb41c4b8b475cb4f3f7165094c229c9e8c4dc0a2a5ff1903e501511221376a1cdb8364c5061a20cae74bc4acd76ceb0abc9fd3217ef9f8c90be402ddf6d8697f4f880dff15bfb7a6b28241ec8fe183c2d59e3f9dfff653c7126f0acb9e64211f42bae12af462b1070bef1ab5e3606872ca10dee15b3249b1a1b958f23134c4bccb7d03200bce420a2f8eb66dcf3644d1423c1b5699003c13ecef4bf38a3b60eedc34033bac1902783dc6d89e2e774188a439c7ebcc0672dbda4ddcfb2794613b0be41315ef778708a70ee7d75165c" }; { cipher = AES_128_GCM; key = h "843ffcf5d2b72694d19ed01d01249412"; iv = h "dbcca32ebf9b804617c3aa9e"; aad = h "00000000000000000000000000000000101112131415161718191a1b1c1d1e1f"; tag = h "3b629ccfbc1119b7319e1dce2cd6fd6d"; plaintext = h "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f" ; ciphertext = h "6268c6fa2a80b2d137467f092f657ac04d89be2beaa623d61b5a868c8f03ff95d3dcee23ad2f1ab3a6c80eaf4b140eb05de3457f0fbc111a6b43d0763aa422a3013cf1dc37fe417d1fbfc449b75d4cc5" } ]
false
Vale.Stdcalls.X64.GCMdecryptOpt.fst
Vale.Stdcalls.X64.GCMdecryptOpt.gcm128_decrypt_opt
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)
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)
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 209, "end_line": 400, "start_col": 0, "start_line": 399 }
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))
{ "checked_file": "/", "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" }
[ { "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 } ]
{ "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" }
false
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)
Prims.Tot
[ "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" ]
[]
false
false
false
false
false
let gcm128_decrypt_opt =
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)
false
Test.Vectors.fst
Test.Vectors.hkdf_vectors
val hkdf_vectors : Prims.list Test.Vectors.hkdf_vector
let hkdf_vectors = [{ // Test Case 1 // Basic test case with SHA-256 ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h"000102030405060708090a0b0c";// (13 octets) info = h"f0f1f2f3f4f5f6f7f8f9";// (10 octets) prk = h"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5";// (32 octets) okm = h"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865";// (42 octets) }; { // Test Case 2 // Test with SHA-256 and longer inputs/outputs ha = SHA2_256; ikm = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f";// (80 octets) salt = h"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf";// (80 octets) info = h"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";// (80 octets) prk = h"06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244";// (32 octets) okm = h"b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87";// (82 octets) }; { // Test Case 3 // Test with SHA-256 and zero-length salt/info ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h""; info = h""; prk = h"19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04";// (32 octets) okm = h"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8";// (42 octets) }]
{ "file_name": "providers/test/Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 254, "start_col": 0, "start_line": 227 }
module Test.Vectors open Test.Lowstarize open EverCrypt.Hash open Spec.Hash.Definitions /// Hash algorithms type hash_alg = EverCrypt.Hash.alg #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" noeq noextract type hash_vector = { (* The input [input] is repeated [repeat] times. *) hash_alg: hash_alg; input: string; output: hex_encoded; repeat: UInt32.t; } noextract let hash_vectors = [{ hash_alg = MD5; input = ""; output = h"d41d8cd98f00b204e9800998ecf8427e"; repeat = 1ul }; { hash_alg = MD5; input = "a"; output = h"0cc175b9c0f1b6a831c399e269772661"; repeat = 1ul }; { hash_alg = MD5; input = "abc"; output = h"900150983cd24fb0d6963f7d28e17f72"; repeat = 1ul }; { hash_alg = MD5; input = "message digest"; output = h"f96b697d7cb7938d525a2f31aaf161d0"; repeat = 1ul }; { hash_alg = MD5; input = "abcdefghijklmnopqrstuvwxyz"; output = h"c3fcd3d76192e4007dfb496cca67e13b"; repeat = 1ul }; { hash_alg = MD5; input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; output = h"d174ab98d277d9f5a5611c2c9f419d9f"; repeat = 1ul }; { hash_alg = MD5; input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; output = h"57edf4a22be3c955ac49da2e2107b67a"; repeat = 1ul }; { hash_alg = SHA1; input = "abc"; output = h"a9993e364706816aba3e25717850c26c9cd0d89d"; repeat = 1ul }; { hash_alg = SHA1; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"84983e441c3bd26ebaae4aa1f95129e5e54670f1"; repeat = 1ul }; { hash_alg = SHA1; input = "a"; output = h"34aa973cd4c4daa4f61eeb2bdbad27316534016f"; repeat = 1000000ul }; { hash_alg = SHA1; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"dea356a2cddd90c7a7ecedc5ebb563934f460452"; repeat = 10ul }; { hash_alg = SHA2_256; input = "abc"; output = h"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; repeat = 1ul }; { hash_alg = SHA2_256; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; repeat = 1ul }; { hash_alg = SHA2_256; input = "a"; output = h"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"; repeat = 1000000ul }; { hash_alg = SHA2_256; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5"; repeat = 10ul }; { hash_alg = SHA2_256; input = "\x19"; output = h"68aa2e2ee5dff96e3355e6c7ee373e3d6a4e17f75f9518d843709c0c9bc3e3d4"; repeat = 1ul };(* { hash_alg = SHA2_256; // 2018.05.26: Don't know how to encode byte literals in strings; this doesn't work // as in OCaml input = "\xe3\xd7\x25\x70\xdc\xdd\x78\x7c\xe3\x88\x7a\xb2\xcd\x68\x46\x52"; output = h"175ee69b02ba9b58e2b0a5fd13819cea573f3940a94f825128cf4209beabb4e8"; repeat = 1ul }; *){ hash_alg = SHA2_384; input = "abc"; output = h"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"; repeat = 1ul }; { hash_alg = SHA2_384; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"; repeat = 1ul }; { hash_alg = SHA2_384; input = "a"; output = h"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"; repeat = 1000000ul }; { hash_alg = SHA2_384; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"2fc64a4f500ddb6828f6a3430b8dd72a368eb7f3a8322a70bc84275b9c0b3ab00d27a5cc3c2d224aa6b61a0d79fb4596"; repeat = 10ul }; { hash_alg = SHA2_512; input = "abc"; output = h"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"; repeat = 1ul }; { hash_alg = SHA2_512; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"; repeat = 1ul }; { hash_alg = SHA2_512; input = "a"; output = h"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"; repeat = 1000000ul }; { hash_alg = SHA2_512; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"89d05ba632c699c31231ded4ffc127d5a894dad412c0e024db872d1abd2ba8141a0f85072a9be1e2aa04cf33c765cb510813a39cd5a84c4acaa64d3f3fb7bae9"; repeat = 10ul } ] noextract let hash_vectors_tmp = List.Tot.map (fun h -> h.hash_alg, h.input, h.output, h.repeat ) hash_vectors // 2018.08.06 SZ: I can't verify this in interactive mode but verifies from the command-line %splice[] (lowstarize_toplevel "hash_vectors_tmp" "hash_vectors_low") /// HMAC noeq noextract type hmac_vector = { ha: hash_alg; key: hex_encoded; data: hex_encoded; output: hex_encoded; } // selected test vectors from // https://tools.ietf.org/html/rfc4231#section-4.2 // pls extend me! noextract let hmac_vectors = [{ ha = SHA2_256; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"; }; { ha = SHA2_384; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6"; }] noextract let hmac_vectors_tmp = List.Tot.map (fun h -> h.ha, h.key, h.data, h.output ) hmac_vectors %splice[] (lowstarize_toplevel "hmac_vectors_tmp" "hmac_vectors_low") /// HMAC_DRBG noextract let hmac_drbg_vectors_tmp = let open Spec.HMAC_DRBG.Test.Vectors in List.Tot.map (fun x -> x.a, h x.entropy_input, h x.nonce, h x.personalization_string, h x.entropy_input_reseed, h x.additional_input_reseed, (h x.additional_input_1, h x.additional_input_2), h x.returned_bits) test_vectors %splice[] (lowstarize_toplevel "hmac_drbg_vectors_tmp" "hmac_drbg_vectors_low") /// HKDF /// https://tools.ietf.org/html/rfc5869.html /// pls extend me! We miss SHA2_384 and SHA2_512 tests /// /// The test is in 2 steps: /// prk <- extract sal ikm /// okm <- expand prk info okmlen noeq noextract type hkdf_vector = { ha: hash_alg; ikm: hex_encoded; // input key materials salt: hex_encoded; // input salt info: hex_encoded; // expansion label prk: hex_encoded; // extracted pseudo-random key (its length is Spec.Hash.Definitions.hash_len ha) okm: hex_encoded; // output: expanded key materials (its length is an input) }
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "EverCrypt.Hash.fsti.checked" ], "interface_file": false, "source_file": "Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Test.Vectors.hkdf_vector
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "Test.Vectors.hkdf_vector", "Test.Vectors.Mkhkdf_vector", "Spec.Hash.Definitions.SHA2_256", "Test.Lowstarize.h", "Prims.Nil" ]
[]
false
false
false
true
false
let hkdf_vectors =
[ { ha = SHA2_256; ikm = h "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; salt = h "000102030405060708090a0b0c"; info = h "f0f1f2f3f4f5f6f7f8f9"; prk = h "077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5"; okm = h "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865" }; { ha = SHA2_256; ikm = h "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f" ; salt = h "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf" ; info = h "b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" ; prk = h "06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244"; okm = h "b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87" }; { ha = SHA2_256; ikm = h "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; salt = h ""; info = h ""; prk = h "19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04"; okm = h "8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8" } ]
false
Test.Vectors.fst
Test.Vectors.aead_vectors_tmp
val aead_vectors_tmp : Prims.list ((((((Test.Vectors.cipher * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded)
let aead_vectors_tmp = List.Tot.map (fun h -> h.cipher, h.key, h.iv, h.aad, h.tag, h.plaintext, h.ciphertext ) aead_vectors
{ "file_name": "providers/test/Test.Vectors.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 572, "start_col": 0, "start_line": 570 }
module Test.Vectors open Test.Lowstarize open EverCrypt.Hash open Spec.Hash.Definitions /// Hash algorithms type hash_alg = EverCrypt.Hash.alg #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" noeq noextract type hash_vector = { (* The input [input] is repeated [repeat] times. *) hash_alg: hash_alg; input: string; output: hex_encoded; repeat: UInt32.t; } noextract let hash_vectors = [{ hash_alg = MD5; input = ""; output = h"d41d8cd98f00b204e9800998ecf8427e"; repeat = 1ul }; { hash_alg = MD5; input = "a"; output = h"0cc175b9c0f1b6a831c399e269772661"; repeat = 1ul }; { hash_alg = MD5; input = "abc"; output = h"900150983cd24fb0d6963f7d28e17f72"; repeat = 1ul }; { hash_alg = MD5; input = "message digest"; output = h"f96b697d7cb7938d525a2f31aaf161d0"; repeat = 1ul }; { hash_alg = MD5; input = "abcdefghijklmnopqrstuvwxyz"; output = h"c3fcd3d76192e4007dfb496cca67e13b"; repeat = 1ul }; { hash_alg = MD5; input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; output = h"d174ab98d277d9f5a5611c2c9f419d9f"; repeat = 1ul }; { hash_alg = MD5; input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; output = h"57edf4a22be3c955ac49da2e2107b67a"; repeat = 1ul }; { hash_alg = SHA1; input = "abc"; output = h"a9993e364706816aba3e25717850c26c9cd0d89d"; repeat = 1ul }; { hash_alg = SHA1; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"84983e441c3bd26ebaae4aa1f95129e5e54670f1"; repeat = 1ul }; { hash_alg = SHA1; input = "a"; output = h"34aa973cd4c4daa4f61eeb2bdbad27316534016f"; repeat = 1000000ul }; { hash_alg = SHA1; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"dea356a2cddd90c7a7ecedc5ebb563934f460452"; repeat = 10ul }; { hash_alg = SHA2_256; input = "abc"; output = h"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; repeat = 1ul }; { hash_alg = SHA2_256; input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; output = h"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; repeat = 1ul }; { hash_alg = SHA2_256; input = "a"; output = h"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"; repeat = 1000000ul }; { hash_alg = SHA2_256; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5"; repeat = 10ul }; { hash_alg = SHA2_256; input = "\x19"; output = h"68aa2e2ee5dff96e3355e6c7ee373e3d6a4e17f75f9518d843709c0c9bc3e3d4"; repeat = 1ul };(* { hash_alg = SHA2_256; // 2018.05.26: Don't know how to encode byte literals in strings; this doesn't work // as in OCaml input = "\xe3\xd7\x25\x70\xdc\xdd\x78\x7c\xe3\x88\x7a\xb2\xcd\x68\x46\x52"; output = h"175ee69b02ba9b58e2b0a5fd13819cea573f3940a94f825128cf4209beabb4e8"; repeat = 1ul }; *){ hash_alg = SHA2_384; input = "abc"; output = h"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"; repeat = 1ul }; { hash_alg = SHA2_384; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"; repeat = 1ul }; { hash_alg = SHA2_384; input = "a"; output = h"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"; repeat = 1000000ul }; { hash_alg = SHA2_384; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"2fc64a4f500ddb6828f6a3430b8dd72a368eb7f3a8322a70bc84275b9c0b3ab00d27a5cc3c2d224aa6b61a0d79fb4596"; repeat = 10ul }; { hash_alg = SHA2_512; input = "abc"; output = h"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"; repeat = 1ul }; { hash_alg = SHA2_512; input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; output = h"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"; repeat = 1ul }; { hash_alg = SHA2_512; input = "a"; output = h"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"; repeat = 1000000ul }; { hash_alg = SHA2_512; input = "0123456701234567012345670123456701234567012345670123456701234567"; output = h"89d05ba632c699c31231ded4ffc127d5a894dad412c0e024db872d1abd2ba8141a0f85072a9be1e2aa04cf33c765cb510813a39cd5a84c4acaa64d3f3fb7bae9"; repeat = 10ul } ] noextract let hash_vectors_tmp = List.Tot.map (fun h -> h.hash_alg, h.input, h.output, h.repeat ) hash_vectors // 2018.08.06 SZ: I can't verify this in interactive mode but verifies from the command-line %splice[] (lowstarize_toplevel "hash_vectors_tmp" "hash_vectors_low") /// HMAC noeq noextract type hmac_vector = { ha: hash_alg; key: hex_encoded; data: hex_encoded; output: hex_encoded; } // selected test vectors from // https://tools.ietf.org/html/rfc4231#section-4.2 // pls extend me! noextract let hmac_vectors = [{ ha = SHA2_256; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"; }; { ha = SHA2_384; key = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; data = h"4869205468657265"; output = h"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6"; }] noextract let hmac_vectors_tmp = List.Tot.map (fun h -> h.ha, h.key, h.data, h.output ) hmac_vectors %splice[] (lowstarize_toplevel "hmac_vectors_tmp" "hmac_vectors_low") /// HMAC_DRBG noextract let hmac_drbg_vectors_tmp = let open Spec.HMAC_DRBG.Test.Vectors in List.Tot.map (fun x -> x.a, h x.entropy_input, h x.nonce, h x.personalization_string, h x.entropy_input_reseed, h x.additional_input_reseed, (h x.additional_input_1, h x.additional_input_2), h x.returned_bits) test_vectors %splice[] (lowstarize_toplevel "hmac_drbg_vectors_tmp" "hmac_drbg_vectors_low") /// HKDF /// https://tools.ietf.org/html/rfc5869.html /// pls extend me! We miss SHA2_384 and SHA2_512 tests /// /// The test is in 2 steps: /// prk <- extract sal ikm /// okm <- expand prk info okmlen noeq noextract type hkdf_vector = { ha: hash_alg; ikm: hex_encoded; // input key materials salt: hex_encoded; // input salt info: hex_encoded; // expansion label prk: hex_encoded; // extracted pseudo-random key (its length is Spec.Hash.Definitions.hash_len ha) okm: hex_encoded; // output: expanded key materials (its length is an input) } noextract let hkdf_vectors = [{ // Test Case 1 // Basic test case with SHA-256 ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h"000102030405060708090a0b0c";// (13 octets) info = h"f0f1f2f3f4f5f6f7f8f9";// (10 octets) prk = h"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5";// (32 octets) okm = h"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865";// (42 octets) }; { // Test Case 2 // Test with SHA-256 and longer inputs/outputs ha = SHA2_256; ikm = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f";// (80 octets) salt = h"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf";// (80 octets) info = h"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";// (80 octets) prk = h"06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244";// (32 octets) okm = h"b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87";// (82 octets) }; { // Test Case 3 // Test with SHA-256 and zero-length salt/info ha = SHA2_256; ikm = h"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";// (22 octets) salt = h""; info = h""; prk = h"19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04";// (32 octets) okm = h"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8";// (42 octets) }] noextract let hkdf_vectors_tmp = List.Tot.map (fun h -> h.ha, h.ikm, h.salt, h.info, h.prk, h.okm ) hkdf_vectors %splice[] (lowstarize_toplevel "hkdf_vectors_tmp" "hkdf_vectors_low") //TODO add test_hkdf, test_hkdf_one as for HMAC /// Cipher block function type block_cipher = | AES128 | AES256 // Funky field names to avoid collisions... noeq noextract type block_cipher_vector = { block: block_cipher; rkey: hex_encoded; plain: hex_encoded; enc: hex_encoded; } noextract let block_cipher_vectors = [ { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"3ad77bb40d7a3660a89ecaf32466ef97" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"f5d3d58503b9699de785895a96fdbaaf" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"43b1cd7f598ece23881b00e3ed030688" }; { block = AES128; rkey = h"2b7e151628aed2a6abf7158809cf4f3c"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"7b0c785e27e8ad3f8223207104725dd4" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"6bc1bee22e409f96e93d7e117393172a"; enc = h"f3eed1bdb5d2a03c064b5a7e3db181f8" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"ae2d8a571e03ac9c9eb76fac45af8e51"; enc = h"591ccb10d410ed26dc5ba74a31362870" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"30c81c46a35ce411e5fbc1191a0a52ef"; enc = h"b6ed21b99ca6f4f9f153e7b1beafed1d" }; { block = AES256; rkey = h"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; plain = h"f69f2445df4f9b17ad2b417be66c3710"; enc = h"23304b7a39f9f3ff067d8d8f9e24ecc7" }] noextract let block_cipher_vectors_tmp = List.Tot.map (fun h -> h.block, h.rkey, h.plain, h.enc ) block_cipher_vectors %splice[] (lowstarize_toplevel "block_cipher_vectors_tmp" "block_cipher_vectors_low") noeq noextract type chacha20_vector = { c20_key: hex_encoded; c20_iv: hex_encoded; c20_ctr: UInt32.t; c20_plain: hex_encoded; c20_cipher: hex_encoded; } noextract let chacha20_vectors = [ { c20_key = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"; c20_iv = h"000000000000004a00000000"; c20_ctr = 1ul; c20_plain = h"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e"; c20_cipher = h"6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d"; }] noextract let chacha20_vectors_tmp = List.Tot.map (fun h -> h.c20_key, h.c20_iv, h.c20_ctr, h.c20_plain, h.c20_cipher ) chacha20_vectors %splice[] (lowstarize_toplevel "chacha20_vectors_tmp" "chacha20_vectors_low") /// AEAD type cipher = | AES_128_GCM | AES_256_GCM | CHACHA20_POLY1305 noeq noextract type aead_vector = { cipher: cipher; key: hex_encoded; iv : hex_encoded; aad: hex_encoded; tag: hex_encoded; plaintext: hex_encoded; ciphertext: hex_encoded; } noextract let aead_vectors = [ { (* rfc7539#page-22 *) cipher = CHACHA20_POLY1305; key = h"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f"; iv = h"070000004041424344454647"; aad = h"50515253c0c1c2c3c4c5c6c7"; tag = h"1ae10b594f09e26a7e902ecbd0600691"; plaintext = h"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e"; ciphertext = h"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116"; }; { cipher = CHACHA20_POLY1305; key = h"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0"; iv = h"000000000102030405060708"; aad = h"f33388860000000000004e91"; tag = h"eead9d67890cbb22392336fea1851f38"; plaintext = h"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d"; ciphertext = h"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"58e2fccefa7e3061367f1d57a4e7455a"; plaintext = h""; ciphertext = h""; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"ab6e47d42cec13bdf53a67b21257bddf"; plaintext = h"00000000000000000000000000000000"; ciphertext = h"0388dace60b6a392f328c2b971b2fe78"; }; { cipher = AES_128_GCM; key = h"feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbaddecaf888"; aad = h""; tag = h"4d5c2af327cd64a62cf35abd2ba6fab4"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255"; ciphertext = h"42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985"; }; { cipher = AES_128_GCM; key = h"feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbaddecaf888"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"5bc94fbc3221a5db94fae95ae7121a47"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091"; }; { cipher = AES_128_GCM; key = h"feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbad"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"3612d2e79e3b0785561be14aaca2fccb"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c742373806900e49f24b22b097544d4896b424989b5e1ebac0f07c23f4598"; }; { cipher = AES_128_GCM; key = h"feffe9928665731c6d6a8f9467308308"; iv = h"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"619cc5aefffe0bfa462af43c1699d050"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca701e4a9a4fba43c90ccdcb281d48c7c6fd62875d2aca417034c34aee5"; }; { cipher = AES_256_GCM; key = h"0000000000000000000000000000000000000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"530f8afbc74536b9a963b4f1c4cb738b"; plaintext = h""; ciphertext = h""; }; { cipher = AES_256_GCM; key = h"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbaddecaf888"; aad = h""; tag = h"b094dac5d93471bdec1a502270e3cc6c"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255"; ciphertext = h"522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad"; }; { cipher = AES_256_GCM; key = h"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbaddecaf888"; aad = h""; tag = h"b094dac5d93471bdec1a502270e3cc6c"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255"; ciphertext = h"522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad"; }; { cipher = AES_256_GCM; key = h"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbaddecaf888"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"76fc6ece0f4e1768cddf8853bb2d551b"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662"; }; { cipher = AES_256_GCM; key = h"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h"cafebabefacedbad"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"3a337dbf46a792c45e454913fe2ea8f2"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0feb582d33934a4f0954cc2363bc73f7862ac430e64abe499f47c9b1f"; }; { cipher = AES_256_GCM; key = h"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308"; iv = h"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b"; aad = h"feedfacedeadbeeffeedfacedeadbeefabaddad2"; tag = h"a44a8266ee1c8eb0c8b5d4cf5ae9f19a"; plaintext = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39"; ciphertext = h"5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad"; tag = h"5fea793a2d6f974d37e68e0cb8ff9492"; plaintext = h""; ciphertext = h""; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"9dd0a376b08e40eb00c35f29f9ea61a4"; plaintext = h"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ciphertext = h"0388dace60b6a392f328c2b971b2fe78f795aaab494b5923f7fd89ff948bc1e0200211214e7394da2089b6acd093abe0"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"98885a3a22bd4742fe7b72172193b163"; plaintext = h"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ciphertext = h"0388dace60b6a392f328c2b971b2fe78f795aaab494b5923f7fd89ff948bc1e0200211214e7394da2089b6acd093abe0c94da219118e297d7b7ebcbcc9c388f28ade7d85a8ee35616f7124a9d5270291"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"000000000000000000000000"; aad = h""; tag = h"cac45f60e31efd3b5a43b98a22ce1aa1"; plaintext = h"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ciphertext = h"0388dace60b6a392f328c2b971b2fe78f795aaab494b5923f7fd89ff948bc1e0200211214e7394da2089b6acd093abe0c94da219118e297d7b7ebcbcc9c388f28ade7d85a8ee35616f7124a9d527029195b84d1b96c690ff2f2de30bf2ec89e00253786e126504f0dab90c48a30321de3345e6b0461e7c9e6c6b7afedde83f40"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"ffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; aad = h""; tag = h"566f8ef683078bfdeeffa869d751a017"; plaintext = h"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ciphertext = h"56b3373ca9ef6e4a2b64fe1e9a17b61425f10d47a75a5fce13efc6bc784af24f4141bdd48cf7c770887afd573cca5418a9aeffcd7c5ceddfc6a78397b9a85b499da558257267caab2ad0b23ca476a53cb17fb41c4b8b475cb4f3f7165094c229c9e8c4dc0a2a5ff1903e501511221376a1cdb8364c5061a20cae74bc4acd76ceb0abc9fd3217ef9f8c90be402ddf6d8697f4f880dff15bfb7a6b28241ec8fe183c2d59e3f9dfff653c7126f0acb9e64211f42bae12af462b1070bef1ab5e3606"; }; { cipher = AES_128_GCM; key = h"00000000000000000000000000000000"; iv = h"ffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; aad = h""; tag = h"8b307f6b33286d0ab026a9ed3fe1e85f"; plaintext = h"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ciphertext = h"56b3373ca9ef6e4a2b64fe1e9a17b61425f10d47a75a5fce13efc6bc784af24f4141bdd48cf7c770887afd573cca5418a9aeffcd7c5ceddfc6a78397b9a85b499da558257267caab2ad0b23ca476a53cb17fb41c4b8b475cb4f3f7165094c229c9e8c4dc0a2a5ff1903e501511221376a1cdb8364c5061a20cae74bc4acd76ceb0abc9fd3217ef9f8c90be402ddf6d8697f4f880dff15bfb7a6b28241ec8fe183c2d59e3f9dfff653c7126f0acb9e64211f42bae12af462b1070bef1ab5e3606872ca10dee15b3249b1a1b958f23134c4bccb7d03200bce420a2f8eb66dcf3644d1423c1b5699003c13ecef4bf38a3b60eedc34033bac1902783dc6d89e2e774188a439c7ebcc0672dbda4ddcfb2794613b0be41315ef778708a70ee7d75165c"; }; { cipher = AES_128_GCM; key = h"843ffcf5d2b72694d19ed01d01249412"; iv = h"dbcca32ebf9b804617c3aa9e"; aad = h"00000000000000000000000000000000101112131415161718191a1b1c1d1e1f"; tag = h"3b629ccfbc1119b7319e1dce2cd6fd6d"; plaintext = h"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f"; ciphertext = h"6268c6fa2a80b2d137467f092f657ac04d89be2beaa623d61b5a868c8f03ff95d3dcee23ad2f1ab3a6c80eaf4b140eb05de3457f0fbc111a6b43d0763aa422a3013cf1dc37fe417d1fbfc449b75d4cc5"; }; ]
{ "checked_file": "/", "dependencies": [ "Test.Lowstarize.fst.checked", "Spec.HMAC_DRBG.Test.Vectors.fst.checked", "Spec.Hash.Definitions.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "EverCrypt.Hash.fsti.checked" ], "interface_file": false, "source_file": "Test.Vectors.fst" }
[ { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Hash", "short_module": null }, { "abbrev": false, "full_module": "Test.Lowstarize", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "Test", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list ((((((Test.Vectors.cipher * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded) * Test.Lowstarize.hex_encoded)
Prims.Tot
[ "total" ]
[]
[ "FStar.List.Tot.Base.map", "Test.Vectors.aead_vector", "FStar.Pervasives.Native.tuple7", "Test.Vectors.cipher", "Test.Lowstarize.hex_encoded", "FStar.Pervasives.Native.Mktuple7", "Test.Vectors.__proj__Mkaead_vector__item__cipher", "Test.Vectors.__proj__Mkaead_vector__item__key", "Test.Vectors.__proj__Mkaead_vector__item__iv", "Test.Vectors.__proj__Mkaead_vector__item__aad", "Test.Vectors.__proj__Mkaead_vector__item__tag", "Test.Vectors.__proj__Mkaead_vector__item__plaintext", "Test.Vectors.__proj__Mkaead_vector__item__ciphertext", "Test.Vectors.aead_vectors" ]
[]
false
false
false
true
false
let aead_vectors_tmp =
List.Tot.map (fun h -> h.cipher, h.key, h.iv, h.aad, h.tag, h.plaintext, h.ciphertext) aead_vectors
false