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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_def | val make_seperated_hash_def (a b c d e f g h: nat32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 a /\ hash.[ 1 ] == to_uint32 b /\
hash.[ 2 ] == to_uint32 c /\ hash.[ 3 ] == to_uint32 d /\ hash.[ 4 ] == to_uint32 e /\
hash.[ 5 ] == to_uint32 f /\ hash.[ 6 ] == to_uint32 g /\ hash.[ 7 ] == to_uint32 h }) | val make_seperated_hash_def (a b c d e f g h: nat32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 a /\ hash.[ 1 ] == to_uint32 b /\
hash.[ 2 ] == to_uint32 c /\ hash.[ 3 ] == to_uint32 d /\ hash.[ 4 ] == to_uint32 e /\
hash.[ 5 ] == to_uint32 f /\ hash.[ 6 ] == to_uint32 g /\ hash.[ 7 ] == to_uint32 h }) | let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 8,
"end_line": 293,
"start_col": 0,
"start_line": 267
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Vale.Def.Words_s.nat32 ->
b: Vale.Def.Words_s.nat32 ->
c: Vale.Def.Words_s.nat32 ->
d: Vale.Def.Words_s.nat32 ->
e: Vale.Def.Words_s.nat32 ->
f: Vale.Def.Words_s.nat32 ->
g: Vale.Def.Words_s.nat32 ->
h: Vale.Def.Words_s.nat32
-> hash:
Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA2_256
{ FStar.Seq.Base.length hash == 8 /\ hash.[ 0 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 a /\
hash.[ 1 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 b /\
hash.[ 2 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 c /\
hash.[ 3 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 d /\
hash.[ 4 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 e /\
hash.[ 5 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 f /\
hash.[ 6 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 g /\
hash.[ 7 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 h } | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Words_s.nat32",
"Prims.unit",
"FStar.Seq.Properties.elim_of_list",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Seq.Base.seq",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Seq.Base.seq_of_list",
"FStar.Pervasives.assert_norm",
"Prims.list",
"Prims.Cons",
"Prims.Nil",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Vale.SHA.PPC64LE.SHA_helpers.to_uint32",
"Spec.Hash.Definitions.words_state",
"Prims.l_and",
"FStar.UInt32.t",
"Spec.SHA2.op_String_Access"
] | [] | false | false | false | false | false | let make_seperated_hash_def (a b c d e f g h: nat32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 a /\ hash.[ 1 ] == to_uint32 b /\
hash.[ 2 ] == to_uint32 c /\ hash.[ 3 ] == to_uint32 d /\ hash.[ 4 ] == to_uint32 e /\
hash.[ 5 ] == to_uint32 f /\ hash.[ 6 ] == to_uint32 g /\ hash.[ 7 ] == to_uint32 h }) =
| let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_vsel32 | val lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b))) | val lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b))) | let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b)) | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 75,
"end_line": 347,
"start_col": 0,
"start_line": 341
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Vale.Def.Words_s.nat32 -> b: Vale.Def.Words_s.nat32 -> c: Vale.Def.Words_s.nat32
-> FStar.Pervasives.Lemma
(ensures
Vale.Def.Sel.isel32 a b c =
Vale.Arch.Types.iand32 c a *^ Vale.Arch.Types.iand32 (Vale.Arch.Types.inot32 c) b) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Words_s.nat32",
"Vale.Arch.TypesNative.lemma_equal_nth",
"Vale.Def.Sel.isel32",
"Vale.Arch.Types.op_Star_Hat",
"Vale.Arch.Types.iand32",
"Vale.Arch.Types.inot32",
"Prims.unit",
"Vale.Arch.TypesNative.reveal_ixor_all",
"Vale.Arch.TypesNative.reveal_inot_all",
"Vale.Arch.TypesNative.reveal_iand_all",
"Prims.l_True",
"Prims.squash",
"Prims.b2t",
"Prims.op_Equality",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_vsel32 (a b c: nat32)
: Lemma (ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b))) =
| reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b)) | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 | val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word a.hi3 /\
hash.[1] == nat32_to_word b.hi3 /\
hash.[2] == nat32_to_word c.hi3 /\
hash.[3] == nat32_to_word d.hi3 /\
hash.[4] == nat32_to_word e.hi3 /\
hash.[5] == nat32_to_word f.hi3 /\
hash.[6] == nat32_to_word g.hi3 /\
hash.[7] == nat32_to_word h.hi3
) | val make_seperated_hash_quad32 (a b c d e f g h:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word a.hi3 /\
hash.[1] == nat32_to_word b.hi3 /\
hash.[2] == nat32_to_word c.hi3 /\
hash.[3] == nat32_to_word d.hi3 /\
hash.[4] == nat32_to_word e.hi3 /\
hash.[5] == nat32_to_word f.hi3 /\
hash.[6] == nat32_to_word g.hi3 /\
hash.[7] == nat32_to_word h.hi3
) | let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 94,
"end_line": 324,
"start_col": 19,
"start_line": 324
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l; | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Vale.Def.Types_s.quad32 ->
b: Vale.Def.Types_s.quad32 ->
c: Vale.Def.Types_s.quad32 ->
d: Vale.Def.Types_s.quad32 ->
e: Vale.Def.Types_s.quad32 ->
f: Vale.Def.Types_s.quad32 ->
g: Vale.Def.Types_s.quad32 ->
h: Vale.Def.Types_s.quad32
-> Prims.Pure Vale.SHA.PPC64LE.SHA_helpers.hash256 | Prims.Pure | [] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.Def.Types_s.quad32",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Spec.SHA2.op_String_Access",
"Vale.SHA.PPC64LE.SHA_helpers.nat32_to_word",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.nat32",
"Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32_def"
] | [] | false | false | false | false | false | let make_seperated_hash_quad32 =
| opaque_make make_seperated_hash_quad32_def | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32_def | val make_seperated_hash_quad32_def (a b c d e f g h: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 a.hi3 /\ hash.[ 1 ] == to_uint32 b.hi3 /\
hash.[ 2 ] == to_uint32 c.hi3 /\ hash.[ 3 ] == to_uint32 d.hi3 /\
hash.[ 4 ] == to_uint32 e.hi3 /\ hash.[ 5 ] == to_uint32 f.hi3 /\
hash.[ 6 ] == to_uint32 g.hi3 /\ hash.[ 7 ] == to_uint32 h.hi3 }) | val make_seperated_hash_quad32_def (a b c d e f g h: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 a.hi3 /\ hash.[ 1 ] == to_uint32 b.hi3 /\
hash.[ 2 ] == to_uint32 c.hi3 /\ hash.[ 3 ] == to_uint32 d.hi3 /\
hash.[ 4 ] == to_uint32 e.hi3 /\ hash.[ 5 ] == to_uint32 f.hi3 /\
hash.[ 6 ] == to_uint32 g.hi3 /\ hash.[ 7 ] == to_uint32 h.hi3 }) | let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 8,
"end_line": 323,
"start_col": 0,
"start_line": 297
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Vale.Def.Types_s.quad32 ->
b: Vale.Def.Types_s.quad32 ->
c: Vale.Def.Types_s.quad32 ->
d: Vale.Def.Types_s.quad32 ->
e: Vale.Def.Types_s.quad32 ->
f: Vale.Def.Types_s.quad32 ->
g: Vale.Def.Types_s.quad32 ->
h: Vale.Def.Types_s.quad32
-> hash:
Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA2_256
{ FStar.Seq.Base.length hash == 8 /\
hash.[ 0 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi3 a) /\
hash.[ 1 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi3 b) /\
hash.[ 2 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi3 c) /\
hash.[ 3 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi3 d) /\
hash.[ 4 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi3 e) /\
hash.[ 5 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi3 f) /\
hash.[ 6 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi3 g) /\
hash.[ 7 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi3 h) } | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.quad32",
"Prims.unit",
"FStar.Seq.Properties.elim_of_list",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Seq.Base.seq",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Seq.Base.seq_of_list",
"FStar.Pervasives.assert_norm",
"Prims.list",
"Prims.Cons",
"Prims.Nil",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Vale.SHA.PPC64LE.SHA_helpers.to_uint32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.nat32",
"Spec.Hash.Definitions.words_state",
"Prims.l_and",
"FStar.UInt32.t",
"Spec.SHA2.op_String_Access"
] | [] | false | false | false | false | false | let make_seperated_hash_quad32_def (a b c d e f g h: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 a.hi3 /\ hash.[ 1 ] == to_uint32 b.hi3 /\
hash.[ 2 ] == to_uint32 c.hi3 /\ hash.[ 3 ] == to_uint32 d.hi3 /\
hash.[ 4 ] == to_uint32 e.hi3 /\ hash.[ 5 ] == to_uint32 f.hi3 /\
hash.[ 6 ] == to_uint32 g.hi3 /\ hash.[ 7 ] == to_uint32 h.hi3 }) =
| let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.ch_256_def | val ch_256_def (x y z: nat32) : (a: nat32{a == (iand32 x y) *^ (iand32 (inot32 x) z)}) | val ch_256_def (x y z: nat32) : (a: nat32{a == (iand32 x y) *^ (iand32 (inot32 x) z)}) | let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 355,
"start_col": 0,
"start_line": 349
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Vale.Def.Words_s.nat32 -> y: Vale.Def.Words_s.nat32 -> z: Vale.Def.Words_s.nat32
-> a:
Vale.Def.Words_s.nat32
{a == Vale.Arch.Types.iand32 x y *^ Vale.Arch.Types.iand32 (Vale.Arch.Types.inot32 x) z} | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Words_s.nat32",
"Vale.SHA2.Wrapper.ch256",
"Prims.unit",
"Vale.Arch.TypesNative.reveal_ixor_all",
"Vale.Arch.TypesNative.reveal_inot_all",
"Vale.Arch.TypesNative.reveal_iand_all",
"Prims.eq2",
"Vale.Arch.Types.op_Star_Hat",
"Vale.Arch.Types.iand32",
"Vale.Arch.Types.inot32"
] | [] | false | false | false | false | false | let ch_256_def (x y z: nat32) : (a: nat32{a == (iand32 x y) *^ (iand32 (inot32 x) z)}) =
| reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_sigma_0_0_partial | val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256)
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block)) | val lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256)
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block)) | let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal () | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 379,
"start_col": 0,
"start_line": 375
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Vale.SHA.PPC64LE.SHA_helpers.counter -> block: Vale.SHA.PPC64LE.SHA_helpers.block_w
-> FStar.Pervasives.Lemma (requires 16 <= t /\ t < Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256)
(ensures
Vale.SHA2.Wrapper.sigma256_0_0 (Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block (t - 15)) ==
Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial t block) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.SHA.PPC64LE.SHA_helpers.counter",
"Vale.SHA.PPC64LE.SHA_helpers.block_w",
"Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial_reveal",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.Hash.Definitions.SHA2_256",
"Prims.squash",
"Prims.eq2",
"Vale.Def.Words_s.nat32",
"Vale.SHA2.Wrapper.sigma256_0_0",
"Vale.SHA.PPC64LE.SHA_helpers.ws_opaque",
"Prims.op_Subtraction",
"Vale.SHA.PPC64LE.SHA_helpers.sigma_0_0_partial",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_sigma_0_0_partial (t: counter) (block: block_w)
: Lemma (requires 16 <= t /\ t < size_k_w (SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t - 15)) == sigma_0_0_partial t block)) =
| sigma_0_0_partial_reveal () | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash | val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word a /\
hash.[1] == nat32_to_word b /\
hash.[2] == nat32_to_word c /\
hash.[3] == nat32_to_word d /\
hash.[4] == nat32_to_word e /\
hash.[5] == nat32_to_word f /\
hash.[6] == nat32_to_word g /\
hash.[7] == nat32_to_word h
) | val make_seperated_hash (a b c d e f g h:nat32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word a /\
hash.[1] == nat32_to_word b /\
hash.[2] == nat32_to_word c /\
hash.[3] == nat32_to_word d /\
hash.[4] == nat32_to_word e /\
hash.[5] == nat32_to_word f /\
hash.[6] == nat32_to_word g /\
hash.[7] == nat32_to_word h
) | let make_seperated_hash = opaque_make make_seperated_hash_def | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 80,
"end_line": 294,
"start_col": 19,
"start_line": 294
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l; | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Vale.Def.Words_s.nat32 ->
b: Vale.Def.Words_s.nat32 ->
c: Vale.Def.Words_s.nat32 ->
d: Vale.Def.Words_s.nat32 ->
e: Vale.Def.Words_s.nat32 ->
f: Vale.Def.Words_s.nat32 ->
g: Vale.Def.Words_s.nat32 ->
h: Vale.Def.Words_s.nat32
-> Prims.Pure Vale.SHA.PPC64LE.SHA_helpers.hash256 | Prims.Pure | [] | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.Def.Words_s.nat32",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Spec.SHA2.op_String_Access",
"Vale.SHA.PPC64LE.SHA_helpers.nat32_to_word",
"Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_def"
] | [] | false | false | false | false | false | let make_seperated_hash =
| opaque_make make_seperated_hash_def | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.maj_256_def | val maj_256_def (x y z: nat32) : (a: nat32{a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))}) | val maj_256_def (x y z: nat32) : (a: nat32{a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))}) | let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 371,
"start_col": 0,
"start_line": 366
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: Vale.Def.Words_s.nat32 -> y: Vale.Def.Words_s.nat32 -> z: Vale.Def.Words_s.nat32
-> a:
Vale.Def.Words_s.nat32
{ a ==
Vale.Arch.Types.iand32 x y *^ (Vale.Arch.Types.iand32 x z *^ Vale.Arch.Types.iand32 y z) } | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Words_s.nat32",
"Vale.SHA2.Wrapper.maj256",
"Prims.unit",
"Vale.Arch.TypesNative.reveal_ixor_all",
"Vale.Arch.TypesNative.reveal_iand_all",
"Prims.eq2",
"Vale.Arch.Types.op_Star_Hat",
"Vale.Arch.Types.iand32"
] | [] | false | false | false | false | false | let maj_256_def (x y z: nat32) : (a: nat32{a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))}) =
| reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_eq_maj_xvsel32 | val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))) | val lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))) | let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))) | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 91,
"end_line": 364,
"start_col": 0,
"start_line": 359
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Vale.Def.Words_s.nat32 -> b: Vale.Def.Words_s.nat32 -> c: Vale.Def.Words_s.nat32
-> FStar.Pervasives.Lemma
(ensures
Vale.Def.Sel.isel32 c b (a *^ b) =
Vale.Arch.Types.iand32 a b *^ (Vale.Arch.Types.iand32 a c *^ Vale.Arch.Types.iand32 b c)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Words_s.nat32",
"Vale.Arch.TypesNative.lemma_equal_nth",
"Vale.Def.Sel.isel32",
"Vale.Arch.Types.op_Star_Hat",
"Vale.Arch.Types.iand32",
"Prims.unit",
"Vale.Arch.TypesNative.reveal_ixor_all",
"Vale.Arch.TypesNative.reveal_iand_all",
"Prims.l_True",
"Prims.squash",
"Prims.b2t",
"Prims.op_Equality",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_eq_maj_xvsel32 (a b c: nat32)
: Lemma (ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))) =
| reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))) | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_make_seperated_hash | val lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h) | val lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h) | let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h)) | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 66,
"end_line": 339,
"start_col": 0,
"start_line": 327
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
hash: Vale.SHA.PPC64LE.SHA_helpers.hash256 ->
a: Vale.Def.Types_s.quad32 ->
b: Vale.Def.Types_s.quad32 ->
c: Vale.Def.Types_s.quad32 ->
d: Vale.Def.Types_s.quad32 ->
e: Vale.Def.Types_s.quad32 ->
f: Vale.Def.Types_s.quad32 ->
g: Vale.Def.Types_s.quad32 ->
h: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length hash == 8 /\
Mkfour?.hi3 a == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 hash.[ 0 ] /\
Mkfour?.hi3 b == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 hash.[ 1 ] /\
Mkfour?.hi3 c == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 hash.[ 2 ] /\
Mkfour?.hi3 d == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 hash.[ 3 ] /\
Mkfour?.hi3 e == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 hash.[ 4 ] /\
Mkfour?.hi3 f == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 hash.[ 5 ] /\
Mkfour?.hi3 g == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 hash.[ 6 ] /\
Mkfour?.hi3 h == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 hash.[ 7 ])
(ensures hash == Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 a b c d e f g h) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Vale.Def.Types_s.quad32",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32",
"Prims.unit",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.nat32",
"Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32",
"Spec.SHA2.op_String_Access",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_make_seperated_hash (hash: hash256) (a b c d e f g h: quad32)
: Lemma
(requires
length hash == 8 /\ a.hi3 == word_to_nat32 hash.[ 0 ] /\ b.hi3 == word_to_nat32 hash.[ 1 ] /\
c.hi3 == word_to_nat32 hash.[ 2 ] /\ d.hi3 == word_to_nat32 hash.[ 3 ] /\
e.hi3 == word_to_nat32 hash.[ 4 ] /\ f.hi3 == word_to_nat32 hash.[ 5 ] /\
g.hi3 == word_to_nat32 hash.[ 6 ] /\ h.hi3 == word_to_nat32 hash.[ 7 ])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h) =
| assert (equal hash (make_seperated_hash_quad32 a b c d e f g h)) | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_sigma_1_1_partial | val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig)) | val lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig)) | let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal () | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 397,
"start_col": 0,
"start_line": 393
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal () | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Vale.SHA.PPC64LE.SHA_helpers.counter ->
block: Vale.SHA.PPC64LE.SHA_helpers.block_w ->
hash_orig: Vale.SHA.PPC64LE.SHA_helpers.hash256
-> FStar.Pervasives.Lemma (requires t < Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256)
(ensures
Vale.SHA2.Wrapper.sigma256_1_1 (Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale
t
block
hash_orig).[ 4 ]) ==
Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial t block hash_orig) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.SHA.PPC64LE.SHA_helpers.counter",
"Vale.SHA.PPC64LE.SHA_helpers.block_w",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial_reveal",
"Prims.unit",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.Hash.Definitions.SHA2_256",
"Prims.squash",
"Prims.eq2",
"Vale.Def.Words_s.nat32",
"Vale.SHA2.Wrapper.sigma256_1_1",
"Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32",
"Spec.SHA2.op_String_Access",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale",
"Vale.SHA.PPC64LE.SHA_helpers.sigma_1_1_partial",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_sigma_1_1_partial (t: counter) (block: block_w) (hash_orig: hash256)
: Lemma (requires t < size_k_w (SHA2_256))
(ensures
(sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[ 4 ])) ==
sigma_1_1_partial t block hash_orig)) =
| sigma_1_1_partial_reveal () | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_add_mod_ws_rearrangement | val lemma_add_mod_ws_rearrangement (a b c d: UInt32.t)
: Lemma (let open Lib.IntTypes in a +. b +. c +. d == d +. c +. b +. a) | val lemma_add_mod_ws_rearrangement (a b c d: UInt32.t)
: Lemma (let open Lib.IntTypes in a +. b +. c +. d == d +. c +. b +. a) | let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
} | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 491,
"start_col": 0,
"start_line": 474
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ()
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
#reset-options "--z3rlimit 20"
let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in
let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in
word_to_nat32 h.[0] == add_wrap t1 t2 /\
word_to_nat32 h.[1] == a0 /\
word_to_nat32 h.[2] == b0 /\
word_to_nat32 h.[3] == c0 /\
word_to_nat32 h.[4] == add_wrap d0 t1 /\
word_to_nat32 h.[5] == e0 /\
word_to_nat32 h.[6] == f0 /\
word_to_nat32 h.[7] == g0))
=
let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
ch_256_reveal ();
maj_256_reveal ();
lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0);
lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t);
lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0));
lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t));
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig;
shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.UInt32.t -> b: FStar.UInt32.t -> c: FStar.UInt32.t -> d: FStar.UInt32.t
-> FStar.Pervasives.Lemma (ensures a +. b +. c +. d == d +. c +. b +. a) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.UInt32.t",
"FStar.Calc.calc_finish",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.eq2",
"Lib.IntTypes.op_Plus_Dot",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_add_mod_commutes",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_add_mod_associates_U32",
"Prims.l_True",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let lemma_add_mod_ws_rearrangement (a b c d: UInt32.t)
: Lemma (let open Lib.IntTypes in a +. b +. c +. d == d +. c +. b +. a) =
| let open Lib.IntTypes in
calc ( == ) {
a +. b +. c +. d;
( == ) { () }
(((a +. b) +. c) +. d);
( == ) { (lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b) }
d +. (c +. (b +. a));
( == ) { (lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a) }
(((d +. c) +. b) +. a);
} | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32_reveal | val make_seperated_hash_quad32_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures
Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 ==
Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32_def) | let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 156,
"end_line": 325,
"start_col": 12,
"start_line": 325
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures
Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 ==
Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32_def) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.Def.Types_s.quad32",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Spec.SHA2.op_String_Access",
"Vale.SHA.PPC64LE.SHA_helpers.nat32_to_word",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.nat32",
"Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32",
"Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32_def"
] | [] | true | false | true | false | false | let make_seperated_hash_quad32_reveal =
| opaque_revealer (`%make_seperated_hash_quad32)
make_seperated_hash_quad32
make_seperated_hash_quad32_def | false |
|
FStar.Int128.fsti | FStar.Int128.ct_abs | val ct_abs (a: t{min_int n < v a}) : Tot (b: t{v b = abs (v a)}) | val ct_abs (a: t{min_int n < v a}) : Tot (b: t{v b = abs (v a)}) | let ct_abs (a:t{min_int n < v a}) : Tot (b:t{v b = abs (v a)}) =
let mask = a >>>^ UInt32.uint_to_t (n - 1) in
if 0 <= v a then
begin
sign_bit_positive (v a);
nth_lemma (v mask) (FStar.Int.zero _);
logxor_lemma_1 (v a)
end
else
begin
sign_bit_negative (v a);
nth_lemma (v mask) (ones _);
logxor_lemma_2 (v a);
lognot_negative (v a);
UInt.lemma_lognot_value #n (to_uint (v a))
end;
(a ^^ mask) -^ mask | {
"file_name": "ulib/FStar.Int128.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 21,
"end_line": 155,
"start_col": 0,
"start_line": 139
} | (*
Copyright 2008-2019 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.Int128
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 128
open FStar.Int
open FStar.Mul
#set-options "--max_fuel 0 --max_ifuel 0"
(* NOTE: anything that you fix/update here should be reflected in [FStar.UIntN.fstp], which is mostly
* a copy-paste of this module. *)
new val t : eqtype
val v (x:t) : Tot (int_t n)
val int_to_t: x:int_t n -> Pure t
(requires True)
(ensures (fun y -> v y = x))
val uv_inv (x : t) : Lemma
(ensures (int_to_t (v x) == x))
[SMTPat (v x)]
val vu_inv (x : int_t n) : Lemma
(ensures (v (int_to_t x) == x))
[SMTPat (int_to_t x)]
val v_inj (x1 x2: t): Lemma
(requires (v x1 == v x2))
(ensures (x1 == x2))
val zero : x:t{v x = 0}
val one : x:t{v x = 1}
val add (a:t) (b:t) : Pure t
(requires (size (v a + v b) n))
(ensures (fun c -> v a + v b = v c))
(* Subtraction primitives *)
val sub (a:t) (b:t) : Pure t
(requires (size (v a - v b) n))
(ensures (fun c -> v a - v b = v c))
(* Multiplication primitives *)
val mul (a:t) (b:t) : Pure t
(requires (size (v a * v b) n))
(ensures (fun c -> v a * v b = v c))
(* Division primitives *)
val div (a:t) (b:t{v b <> 0}) : Pure t
// division overflows on INT_MIN / -1
(requires (size (v a / v b) n))
(ensures (fun c -> v a / v b = v c))
(* Modulo primitives *)
(* If a/b is not representable the result of a%b is undefind *)
val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires (size (v a / v b) n))
(ensures (fun c -> FStar.Int.mod (v a) (v b) = v c))
(* Bitwise operators *)
val logand (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logand` v y = v z))
val logxor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logxor` v y == v z))
val logor (x:t) (y:t) : Pure t
(requires True)
(ensures (fun z -> v x `logor` v y == v z))
val lognot (x:t) : Pure t
(requires True)
(ensures (fun z -> lognot (v x) == v z))
(* Shift operators *)
(** If a is negative the result is implementation-defined *)
val shift_right (a:t) (s:UInt32.t) : Pure t
(requires (0 <= v a /\ UInt32.v s < n))
(ensures (fun c -> FStar.Int.shift_right (v a) (UInt32.v s) = v c))
(** If a is negative or a * pow2 s is not representable the result is undefined *)
val shift_left (a:t) (s:UInt32.t) : Pure t
(requires (0 <= v a /\ v a * pow2 (UInt32.v s) <= max_int n /\ UInt32.v s < n))
(ensures (fun c -> FStar.Int.shift_left (v a) (UInt32.v s) = v c))
val shift_arithmetic_right (a:t) (s:UInt32.t) : Pure t
(requires (UInt32.v s < n))
(ensures (fun c -> FStar.Int.shift_arithmetic_right (v a) (UInt32.v s) = v c))
(* Comparison operators *)
let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b)
let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b)
let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b)
let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b)
let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b)
(* Infix notations *)
unfold let op_Plus_Hat = add
unfold let op_Subtraction_Hat = sub
unfold let op_Star_Hat = mul
unfold let op_Slash_Hat = div
unfold let op_Percent_Hat = rem
unfold let op_Hat_Hat = logxor
unfold let op_Amp_Hat = logand
unfold let op_Bar_Hat = logor
unfold let op_Less_Less_Hat = shift_left
unfold let op_Greater_Greater_Hat = shift_right
unfold let op_Greater_Greater_Greater_Hat = shift_arithmetic_right
unfold let op_Equals_Hat = eq
unfold let op_Greater_Hat = gt
unfold let op_Greater_Equals_Hat = gte
unfold let op_Less_Hat = lt
unfold let op_Less_Equals_Hat = lte | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int128.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Int",
"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": 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": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: FStar.Int128.t{FStar.Int.min_int FStar.Int128.n < FStar.Int128.v a}
-> b: FStar.Int128.t{FStar.Int128.v b = Prims.abs (FStar.Int128.v a)} | Prims.Tot | [
"total"
] | [] | [
"FStar.Int128.t",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Int.min_int",
"FStar.Int128.n",
"FStar.Int128.v",
"FStar.Int128.op_Subtraction_Hat",
"FStar.Int128.op_Hat_Hat",
"Prims.unit",
"Prims.op_LessThanOrEqual",
"FStar.Int.logxor_lemma_1",
"FStar.Int.nth_lemma",
"FStar.Int.zero",
"FStar.Int.sign_bit_positive",
"Prims.bool",
"FStar.UInt.lemma_lognot_value",
"FStar.Int.to_uint",
"FStar.Int.lognot_negative",
"FStar.Int.logxor_lemma_2",
"FStar.Int.ones",
"FStar.Int.sign_bit_negative",
"FStar.Int128.op_Greater_Greater_Greater_Hat",
"FStar.UInt32.uint_to_t",
"Prims.op_Subtraction",
"Prims.op_Equality",
"Prims.int",
"Prims.abs"
] | [] | false | false | false | false | false | let ct_abs (a: t{min_int n < v a}) : Tot (b: t{v b = abs (v a)}) =
| let mask = a >>>^ UInt32.uint_to_t (n - 1) in
if 0 <= v a
then
(sign_bit_positive (v a);
nth_lemma (v mask) (FStar.Int.zero _);
logxor_lemma_1 (v a))
else
(sign_bit_negative (v a);
nth_lemma (v mask) (ones _);
logxor_lemma_2 (v a);
lognot_negative (v a);
UInt.lemma_lognot_value #n (to_uint (v a)));
(a ^^ mask) -^ mask | false |
Ariadne.fst | Ariadne.log_pre' | val log_pre' (c: ctr) : relation (list (backup c)) | val log_pre' (c: ctr) : relation (list (backup c)) | let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2 | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 81,
"end_line": 95,
"start_col": 0,
"start_line": 95
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | c: Ariadne.ctr -> FStar.Preorder.relation (Prims.list (Ariadne.backup c)) | Prims.Tot | [
"total"
] | [] | [
"Ariadne.ctr",
"Prims.list",
"Ariadne.backup",
"Ariadne.suffix_of",
"FStar.Preorder.relation"
] | [] | false | false | false | false | false | let log_pre' (c: ctr) : relation (list (backup c)) =
| fun l1 l2 -> l1 `suffix_of` l2 | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_le_bytes_to_hash_quads_part1 | val lemma_le_bytes_to_hash_quads_part1 (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s)) | val lemma_le_bytes_to_hash_quads_part1 (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s)) | let lemma_le_bytes_to_hash_quads_part1 (s:seq quad32) : Lemma
(requires length s == 2)
(ensures le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s))
=
let lhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
assert (lhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)));
le_seq_quad32_to_bytes_reveal ();
Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s);
() | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 664,
"start_col": 0,
"start_line": 655
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ()
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
#reset-options "--z3rlimit 20"
let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in
let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in
word_to_nat32 h.[0] == add_wrap t1 t2 /\
word_to_nat32 h.[1] == a0 /\
word_to_nat32 h.[2] == b0 /\
word_to_nat32 h.[3] == c0 /\
word_to_nat32 h.[4] == add_wrap d0 t1 /\
word_to_nat32 h.[5] == e0 /\
word_to_nat32 h.[6] == f0 /\
word_to_nat32 h.[7] == g0))
=
let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
ch_256_reveal ();
maj_256_reveal ();
lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0);
lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t);
lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0));
lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t));
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig;
shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
#reset-options "--fuel 1 --z3rlimit 50"
let lemma_ws_opaque (block:block_w) (t:counter) : Lemma
(requires 16 <= t && t < size_k_w_256)
(ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16))))
=
let t16 = ws SHA2_256 block (t - 16) in
let t15 = ws SHA2_256 block (t - 15) in
let t7 = ws SHA2_256 block (t - 7) in
let t2 = ws SHA2_256 block (t - 2) in
let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
calc (==) {
ws_opaque block t;
(==) { Pervasives.reveal_opaque (`%ws) ws }
vv ((s1 +. t7 +. s0) +. t16);
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7 +. s0)) (ws_opaque block (t-16)) }
add_wrap (vv ((s1 +. t7) +. s0)) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7)) sigma0 }
add_wrap (add_wrap (vv (s1 +. t7)) sigma0) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod sigma1 (ws_opaque block (t-7)) }
add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16));
}
#reset-options "--fuel 0 --ifuel 0 --z3rlimit 20"
let translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old:quad32) : Lemma
(requires a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old)
(ensures (
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
let update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a b c d e f g h ==
repeat_range_vale_64 block hash_orig /\
a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old))
(ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block))
=
let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec r (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
r (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
r 64;
translate_hash_update a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_seperated_hash_quad32 a' b' c' d' e' f' g' h') (update_block hash_orig block));
()
#push-options "--max_fuel 1"
let lemma_slice_commutes_reverse_bytes_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_quad32_seq s) 0 pivot == reverse_bytes_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_quad32_seq s in
let srs = slice (reverse_bytes_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
=
let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
lemma_slice_commutes_reverse_bytes_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_quad32_seq s) 0 (bound + 4));
if bound = 0 then ()
else (
let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()
)
#pop-options
#push-options "--max_fuel 1"
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block_be qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
#pop-options | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length s == 2)
(ensures
Vale.SHA.PPC64LE.SHA_helpers.le_bytes_to_hash (Vale.Def.Types_s.le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map Vale.SHA.PPC64LE.SHA_helpers.nat32_to_word
(Vale.Def.Words.Seq_s.seq_four_to_seq_LE s)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Prims.unit",
"Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE",
"Vale.Def.Words.Seq_s.seq_four_to_seq_LE",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.le_seq_quad32_to_bytes_reveal",
"Prims._assert",
"Prims.eq2",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Vale.Lib.Seqs_s.seq_map",
"Vale.Def.Words_s.nat32",
"Vale.SHA.PPC64LE.SHA_helpers.nat32_to_word",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Vale.SHA.PPC64LE.SHA_helpers.le_bytes_to_hash",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_le_bytes_to_hash_quads_part1 (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s)) =
| let lhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
assert (lhs ==
Vale.Lib.Seqs_s.seq_map nat32_to_word
(Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)));
le_seq_quad32_to_bytes_reveal ();
Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s);
() | false |
Ariadne.fst | Ariadne.pre1 | val pre1 : c: Ariadne.case -> Prims.logical | let pre1 c = Writing? c \/ Crash? c | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 35,
"end_line": 159,
"start_col": 0,
"start_line": 159
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2
let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2
let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c
type log (c:ctr) = mref (list (backup c)) (log_pre c)
type key (c:ctr) = log c
// Private datatype constructor for modeling hardware protection; packaging
// the enclave capabilities to use the monotonic counter c and backup key k.
noeq type protected =
| Protect: c:ctr -> k:key c -> protected
val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v))
let create v =
let c = alloc (Counter 0 (Ok v)) in
let r = (0,v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k
// Privileged code calling back into fallible host code: this may
// fail, in which case we still conservatively assume the host gets
// the saved record (although we can't rely on it for recovery).
let pre0 c w =
match c with
| Ok u -> True
| Recover u v
| Writing u v
| Crash u v -> w==u \/ w==v
let step0 c w =
match c with
| Ok u -> Writing w u
| Recover u v -> if w=u then Writing u v else Crash w u
| Writing u v
| Crash u v -> if w=u then Crash w v else Crash w u
val save: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
pre0 c0 w)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter n c0 = sel h0 c in
pre0 c0 w /\ (
let c1 = step0 c0 w in
sel h1 c == Counter n c1))
let save p w =
let Protect c k = p in
let Counter n c0 = read c in
let c1 = step0 c0 w in
write c (Counter n c1);
let r = (n+1,w) in
witness (saved_backup c r);
let log0 = read k in
write k (r::log0)
// Incrementing the counter is privileged code;
// it may fail before or after incrementing c. | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | c: Ariadne.case -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Ariadne.case",
"Prims.l_or",
"Prims.b2t",
"Ariadne.uu___is_Writing",
"Ariadne.uu___is_Crash",
"Prims.logical"
] | [] | false | false | false | true | true | let pre1 c =
| Writing? c \/ Crash? c | false |
|
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_slice_commutes_reverse_bytes_quad32_seq | val lemma_slice_commutes_reverse_bytes_quad32_seq (s: seq quad32) (pivot: nat)
: Lemma (requires pivot <= length s)
(ensures
slice (reverse_bytes_quad32_seq s) 0 pivot == reverse_bytes_quad32_seq (slice s 0 pivot)) | val lemma_slice_commutes_reverse_bytes_quad32_seq (s: seq quad32) (pivot: nat)
: Lemma (requires pivot <= length s)
(ensures
slice (reverse_bytes_quad32_seq s) 0 pivot == reverse_bytes_quad32_seq (slice s 0 pivot)) | let lemma_slice_commutes_reverse_bytes_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_quad32_seq s) 0 pivot == reverse_bytes_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_quad32_seq s in
let srs = slice (reverse_bytes_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_quad32_seq empty));
()
) else (
assert (equal srs rss)
) | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 602,
"start_col": 0,
"start_line": 587
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ()
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
#reset-options "--z3rlimit 20"
let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in
let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in
word_to_nat32 h.[0] == add_wrap t1 t2 /\
word_to_nat32 h.[1] == a0 /\
word_to_nat32 h.[2] == b0 /\
word_to_nat32 h.[3] == c0 /\
word_to_nat32 h.[4] == add_wrap d0 t1 /\
word_to_nat32 h.[5] == e0 /\
word_to_nat32 h.[6] == f0 /\
word_to_nat32 h.[7] == g0))
=
let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
ch_256_reveal ();
maj_256_reveal ();
lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0);
lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t);
lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0));
lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t));
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig;
shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
#reset-options "--fuel 1 --z3rlimit 50"
let lemma_ws_opaque (block:block_w) (t:counter) : Lemma
(requires 16 <= t && t < size_k_w_256)
(ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16))))
=
let t16 = ws SHA2_256 block (t - 16) in
let t15 = ws SHA2_256 block (t - 15) in
let t7 = ws SHA2_256 block (t - 7) in
let t2 = ws SHA2_256 block (t - 2) in
let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
calc (==) {
ws_opaque block t;
(==) { Pervasives.reveal_opaque (`%ws) ws }
vv ((s1 +. t7 +. s0) +. t16);
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7 +. s0)) (ws_opaque block (t-16)) }
add_wrap (vv ((s1 +. t7) +. s0)) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7)) sigma0 }
add_wrap (add_wrap (vv (s1 +. t7)) sigma0) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod sigma1 (ws_opaque block (t-7)) }
add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16));
}
#reset-options "--fuel 0 --ifuel 0 --z3rlimit 20"
let translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old:quad32) : Lemma
(requires a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old)
(ensures (
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
let update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a b c d e f g h ==
repeat_range_vale_64 block hash_orig /\
a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old))
(ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block))
=
let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec r (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
r (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
r 64;
translate_hash_update a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_seperated_hash_quad32 a' b' c' d' e' f' g' h') (update_block hash_orig block));
() | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> pivot: Prims.nat
-> FStar.Pervasives.Lemma (requires pivot <= FStar.Seq.Base.length s)
(ensures
FStar.Seq.Base.slice (Vale.Arch.Types.reverse_bytes_quad32_seq s) 0 pivot ==
Vale.Arch.Types.reverse_bytes_quad32_seq (FStar.Seq.Base.slice s 0 pivot)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.empty",
"Vale.Arch.Types.reverse_bytes_quad32_seq",
"Prims.bool",
"FStar.Seq.Base.slice",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"Prims.squash",
"Prims.eq2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let lemma_slice_commutes_reverse_bytes_quad32_seq (s: seq quad32) (pivot: nat)
: Lemma (requires pivot <= length s)
(ensures
slice (reverse_bytes_quad32_seq s) 0 pivot == reverse_bytes_quad32_seq (slice s 0 pivot)) =
| let rs = reverse_bytes_quad32_seq s in
let srs = slice (reverse_bytes_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_quad32_seq ss in
if pivot = 0
then
(assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_quad32_seq empty));
())
else (assert (equal srs rss)) | false |
Ariadne.fst | Ariadne.suffix_of | val suffix_of : l1: Prims.list (Ariadne.backup c) -> l2: Prims.list (Ariadne.backup c) -> Prims.logical | let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2 | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 36,
"end_line": 93,
"start_col": 0,
"start_line": 92
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | l1: Prims.list (Ariadne.backup c) -> l2: Prims.list (Ariadne.backup c) -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Ariadne.ctr",
"Prims.list",
"Ariadne.backup",
"Prims.l_or",
"Prims.eq2",
"FStar.List.Tot.Base.strict_suffix_of",
"Prims.logical"
] | [] | false | false | false | false | true | let suffix_of (#c: ctr) (l1 l2: list (backup c)) =
| l1 == l2 \/ strict_suffix_of l1 l2 | false |
|
Vale.X64.InsLemmas.fsti | Vale.X64.InsLemmas.make_instr_annotate | val make_instr_annotate
(#outs: list instr_out)
(#args: list instr_operand)
(#havoc_flags: flag_havoc)
(i: instr_t outs args havoc_flags)
(ann: S.instr_annotation (InstrTypeRecord i))
: make_instr_t outs args | val make_instr_annotate
(#outs: list instr_out)
(#args: list instr_operand)
(#havoc_flags: flag_havoc)
(i: instr_t outs args havoc_flags)
(ann: S.instr_annotation (InstrTypeRecord i))
: make_instr_t outs args | let make_instr_annotate
(#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc)
(i:instr_t outs args havoc_flags) (ann:S.instr_annotation (InstrTypeRecord i))
: make_instr_t outs args =
make_instr_outs outs args (fun oprs -> BC.Instr (InstrTypeRecord i) oprs ann) | {
"file_name": "vale/code/arch/x64/Vale.X64.InsLemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 79,
"end_line": 78,
"start_col": 0,
"start_line": 74
} | module Vale.X64.InsLemmas
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Decls
open Vale.X64.Memory
module BC = Vale.X64.Bytes_Code_s
module S = Vale.X64.Machine_Semantics_s
let has_taint128 (o:operand128) (t:taint) : bool =
match o with
| OMem (_, t') | OStack (_, t') -> t = t'
| _ -> true
val lemma_valid_src_operand64_and_taint (o:operand64) (s:vale_state) : Lemma
(requires valid_operand o s)
(ensures S.valid_src_operand64_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand64_and_taint o (state_to_S s))]
val lemma_valid_src_operand128_and_taint (o:operand128) (s:vale_state) : Lemma
(requires valid_operand128 o s)
(ensures S.valid_src_operand128_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand128_and_taint o (state_to_S s))]
[@instr_attr]
let rec make_instr_t_args (args:list instr_operand) : Type0 =
match normal args with
| [] -> S.ins
| (IOpEx i)::args -> arrow (instr_operand_t i) (make_instr_t_args args)
| (IOpIm _)::args -> make_instr_t_args args
[@instr_attr]
let rec make_instr_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match normal outs with
| [] -> make_instr_t_args args
| (_, IOpEx i)::outs -> arrow (instr_operand_t i) (make_instr_t outs args)
| (_, IOpIm _)::outs -> make_instr_t outs args
[@instr_attr]
let rec make_instr_args
(args:list instr_operand) (k:arrow (instr_operands_t_args args) S.ins)
: make_instr_t_args args =
match args with
| [] -> k ()
| (IOpEx i)::args -> fun (o:instr_operand_t i) ->
let k = coerce #(arrow (instr_operand_t i & instr_operands_t_args args) S.ins) k in // REVIEW: workaround for F* -> OCaml bug
let k (oprs:instr_operands_t_args args) : S.ins = k (o, oprs) in
make_instr_args args k
| (IOpIm i)::args -> coerce (make_instr_args args (coerce #(arrow (instr_operands_t_args args) S.ins) k))
[@instr_attr]
let rec make_instr_outs
(outs:list instr_out) (args:list instr_operand) (k:arrow (instr_operands_t outs args) S.ins)
: make_instr_t outs args =
match outs with
| [] -> make_instr_args args k
| (b, IOpEx i)::outs -> fun (o:instr_operand_t i) ->
let k = coerce #(arrow (instr_operand_t i & instr_operands_t outs args) S.ins) k in // REVIEW: workaround for F* -> OCaml bug
let k (oprs:instr_operands_t outs args) = k (o, oprs) in
make_instr_outs outs args k
| (_, IOpIm i)::outs -> coerce (make_instr_outs outs args (coerce #(arrow (instr_operands_t outs args) S.ins) k))
[@instr_attr]
let make_instr
(#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc)
(i:instr_t outs args havoc_flags)
: make_instr_t outs args =
make_instr_outs outs args (fun oprs -> BC.Instr (InstrTypeRecord i) oprs S.AnnotateNone) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsLemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 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 |
i: Vale.X64.Instruction_s.instr_t outs args havoc_flags ->
ann: Vale.X64.Machine_Semantics_s.instr_annotation (Vale.X64.Instruction_s.InstrTypeRecord i)
-> Vale.X64.InsLemmas.make_instr_t outs args | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.flag_havoc",
"Vale.X64.Instruction_s.instr_t",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Vale.X64.InsLemmas.make_instr_outs",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Bytes_Code_s.Instr",
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.InsLemmas.make_instr_t"
] | [] | false | false | false | false | false | let make_instr_annotate
(#outs: list instr_out)
(#args: list instr_operand)
(#havoc_flags: flag_havoc)
(i: instr_t outs args havoc_flags)
(ann: S.instr_annotation (InstrTypeRecord i))
: make_instr_t outs args =
| make_instr_outs outs args (fun oprs -> BC.Instr (InstrTypeRecord i) oprs ann) | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_sigma_0_1_partial | val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256)
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block)) | val lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256)
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block)) | let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal () | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 385,
"start_col": 0,
"start_line": 381
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal () | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Vale.SHA.PPC64LE.SHA_helpers.counter -> block: Vale.SHA.PPC64LE.SHA_helpers.block_w
-> FStar.Pervasives.Lemma (requires 16 <= t /\ t < Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256)
(ensures
Vale.SHA2.Wrapper.sigma256_0_1 (Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block (t - 2)) ==
Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial t block) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.SHA.PPC64LE.SHA_helpers.counter",
"Vale.SHA.PPC64LE.SHA_helpers.block_w",
"Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial_reveal",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.Hash.Definitions.SHA2_256",
"Prims.squash",
"Prims.eq2",
"Vale.Def.Words_s.nat32",
"Vale.SHA2.Wrapper.sigma256_0_1",
"Vale.SHA.PPC64LE.SHA_helpers.ws_opaque",
"Prims.op_Subtraction",
"Vale.SHA.PPC64LE.SHA_helpers.sigma_0_1_partial",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_sigma_0_1_partial (t: counter) (block: block_w)
: Lemma (requires 16 <= t /\ t < size_k_w (SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t - 2)) == sigma_0_1_partial t block)) =
| sigma_0_1_partial_reveal () | false |
FStar.Classical.Sugar.fsti | FStar.Classical.Sugar.implies_elim | val implies_elim: p: Type -> q: Type -> squash (p ==> q) -> f: (unit -> Tot (squash p)) -> squash q | val implies_elim: p: Type -> q: Type -> squash (p ==> q) -> f: (unit -> Tot (squash p)) -> squash q | let implies_elim
(p:Type)
(q:Type)
(_:squash (p ==> q))
(f:unit -> Tot (squash p))
: squash q
= f() | {
"file_name": "ulib/FStar.Classical.Sugar.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 78,
"start_col": 0,
"start_line": 72
} | (*
Copyright 2021 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.Classical.Sugar
/// This module provides a few combinators that are targeted
/// by the desugaring phase of the F* front end
///
/// The combinators it provides are fairly standard, except for one
/// subtlety. In F*, the typechecking of terms formed using the
/// logical connectives is biased from left to right. That is:
///
/// * In [p /\ q] and [p ==> q], the well-typedness of [q] is in a
/// context assuming [squash p]
///
/// * In [p \/ q], the well-typedness of [q] is in a context assuming
/// [squash (~p)]
///
/// So, many of these combinators reflect that bias by taking as
/// instantiations for [q] functions that depend on [squash p] or
/// [squash (~p)].
///
/// The other subtlety is that the when using these combinators, we
/// encapsulate any proof terms provided by the caller within a
/// thunk. This is to ensure that if, for instance, the caller simply
/// admits a goal, that they do not inadvertently discard any proof
/// obligations in the remainder of their programs.
///
/// For example, consider the difference between
///
/// 1. exists_intro a p v (admit()); rest
///
/// and
///
/// 2. exists_intro a p v (fun _ -> admit()); rest
///
/// In (1) the proof of rest is admitted also.
(** Eliminate a universal quantifier by providing an instantiation *)
val forall_elim
(#a:Type)
(#p:a -> Type)
(v:a)
(f:squash (forall (x:a). p x))
: Tot (squash (p v))
(** Eliminate an existential quantifier into a proof of a goal [q] *)
val exists_elim
(#t:Type)
(#p:t -> Type)
(#q:Type)
($s_ex_p: squash (exists (x:t). p x))
(f: (x:t -> squash (p x) -> Tot (squash q)))
: Tot (squash q)
(** Eliminate an implication, by providing a proof of the hypothesis | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Classical.Sugar.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": 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 | p: Type0 -> q: Type0 -> _: Prims.squash (p ==> q) -> f: (_: Prims.unit -> Prims.squash p)
-> Prims.squash q | Prims.Tot | [
"total"
] | [] | [
"Prims.squash",
"Prims.l_imp",
"Prims.unit"
] | [] | false | false | true | true | false | let implies_elim (p: Type) (q: Type) (_: squash (p ==> q)) (f: (unit -> Tot (squash p))) : squash q =
| f () | false |
Vale.X64.InsLemmas.fsti | Vale.X64.InsLemmas.make_instr | val make_instr
(#outs: list instr_out)
(#args: list instr_operand)
(#havoc_flags: flag_havoc)
(i: instr_t outs args havoc_flags)
: make_instr_t outs args | val make_instr
(#outs: list instr_out)
(#args: list instr_operand)
(#havoc_flags: flag_havoc)
(i: instr_t outs args havoc_flags)
: make_instr_t outs args | let make_instr
(#outs:list instr_out) (#args:list instr_operand) (#havoc_flags:flag_havoc)
(i:instr_t outs args havoc_flags)
: make_instr_t outs args =
make_instr_outs outs args (fun oprs -> BC.Instr (InstrTypeRecord i) oprs S.AnnotateNone) | {
"file_name": "vale/code/arch/x64/Vale.X64.InsLemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 90,
"end_line": 71,
"start_col": 0,
"start_line": 67
} | module Vale.X64.InsLemmas
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Decls
open Vale.X64.Memory
module BC = Vale.X64.Bytes_Code_s
module S = Vale.X64.Machine_Semantics_s
let has_taint128 (o:operand128) (t:taint) : bool =
match o with
| OMem (_, t') | OStack (_, t') -> t = t'
| _ -> true
val lemma_valid_src_operand64_and_taint (o:operand64) (s:vale_state) : Lemma
(requires valid_operand o s)
(ensures S.valid_src_operand64_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand64_and_taint o (state_to_S s))]
val lemma_valid_src_operand128_and_taint (o:operand128) (s:vale_state) : Lemma
(requires valid_operand128 o s)
(ensures S.valid_src_operand128_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand128_and_taint o (state_to_S s))]
[@instr_attr]
let rec make_instr_t_args (args:list instr_operand) : Type0 =
match normal args with
| [] -> S.ins
| (IOpEx i)::args -> arrow (instr_operand_t i) (make_instr_t_args args)
| (IOpIm _)::args -> make_instr_t_args args
[@instr_attr]
let rec make_instr_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match normal outs with
| [] -> make_instr_t_args args
| (_, IOpEx i)::outs -> arrow (instr_operand_t i) (make_instr_t outs args)
| (_, IOpIm _)::outs -> make_instr_t outs args
[@instr_attr]
let rec make_instr_args
(args:list instr_operand) (k:arrow (instr_operands_t_args args) S.ins)
: make_instr_t_args args =
match args with
| [] -> k ()
| (IOpEx i)::args -> fun (o:instr_operand_t i) ->
let k = coerce #(arrow (instr_operand_t i & instr_operands_t_args args) S.ins) k in // REVIEW: workaround for F* -> OCaml bug
let k (oprs:instr_operands_t_args args) : S.ins = k (o, oprs) in
make_instr_args args k
| (IOpIm i)::args -> coerce (make_instr_args args (coerce #(arrow (instr_operands_t_args args) S.ins) k))
[@instr_attr]
let rec make_instr_outs
(outs:list instr_out) (args:list instr_operand) (k:arrow (instr_operands_t outs args) S.ins)
: make_instr_t outs args =
match outs with
| [] -> make_instr_args args k
| (b, IOpEx i)::outs -> fun (o:instr_operand_t i) ->
let k = coerce #(arrow (instr_operand_t i & instr_operands_t outs args) S.ins) k in // REVIEW: workaround for F* -> OCaml bug
let k (oprs:instr_operands_t outs args) = k (o, oprs) in
make_instr_outs outs args k
| (_, IOpIm i)::outs -> coerce (make_instr_outs outs args (coerce #(arrow (instr_operands_t outs args) S.ins) k)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsLemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 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 | i: Vale.X64.Instruction_s.instr_t outs args havoc_flags -> Vale.X64.InsLemmas.make_instr_t outs args | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.flag_havoc",
"Vale.X64.Instruction_s.instr_t",
"Vale.X64.InsLemmas.make_instr_outs",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Bytes_Code_s.Instr",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Vale.X64.Machine_Semantics_s.AnnotateNone",
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.InsLemmas.make_instr_t"
] | [] | false | false | false | false | false | let make_instr
(#outs: list instr_out)
(#args: list instr_operand)
(#havoc_flags: flag_havoc)
(i: instr_t outs args havoc_flags)
: make_instr_t outs args =
| make_instr_outs outs args (fun oprs -> BC.Instr (InstrTypeRecord i) oprs S.AnnotateNone) | false |
Hacl.Impl.RSAPSS.Padding.fst | Hacl.Impl.RSAPSS.Padding.pss_verify_ | val pss_verify_:
a:Hash.hash_alg{S.hash_is_supported a}
-> saltLen:salt_len_t a
-> msgLen:msg_len_t a
-> msg:lbuffer uint8 msgLen
-> emBits:em_len_t a saltLen
-> em:lbuffer uint8 (BD.blocks emBits 8ul) ->
Stack bool
(requires fun h -> live h msg /\ live h em /\ disjoint em msg)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.pss_verify_ a (v saltLen) (v msgLen) (as_seq h0 msg) (v emBits) (as_seq h0 em)) | val pss_verify_:
a:Hash.hash_alg{S.hash_is_supported a}
-> saltLen:salt_len_t a
-> msgLen:msg_len_t a
-> msg:lbuffer uint8 msgLen
-> emBits:em_len_t a saltLen
-> em:lbuffer uint8 (BD.blocks emBits 8ul) ->
Stack bool
(requires fun h -> live h msg /\ live h em /\ disjoint em msg)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.pss_verify_ a (v saltLen) (v msgLen) (as_seq h0 msg) (v emBits) (as_seq h0 em)) | let pss_verify_ a saltLen msgLen msg emBits em =
push_frame ();
let emLen = BD.blocks emBits 8ul in
let hLen = hash_len a in
let m1Hash0 = create hLen (u8 0) in
let dbLen = emLen -! hLen -! 1ul in
let maskedDB = sub em 0ul dbLen in
let m1Hash = sub em dbLen hLen in
let dbMask = create dbLen (u8 0) in
mgf_hash a hLen m1Hash dbLen dbMask;
xor_bytes dbLen dbMask maskedDB;
db_zero dbLen dbMask emBits;
let padLen = emLen -! saltLen -! hLen -! 1ul in
let pad2 = create padLen (u8 0) in
pad2.(padLen -! 1ul) <- u8 0x01;
let pad = sub dbMask 0ul padLen in
let salt = sub dbMask padLen saltLen in
let res =
if not (Lib.ByteBuffer.lbytes_eq #padLen pad pad2) then false
else begin
get_m1Hash a saltLen salt msgLen msg hLen m1Hash0;
Lib.ByteBuffer.lbytes_eq #hLen m1Hash0 m1Hash end in
pop_frame ();
res | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.Padding.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 221,
"start_col": 0,
"start_line": 193
} | module Hacl.Impl.RSAPSS.Padding
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.RSAPSS.MGF
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
module S = Spec.RSAPSS
module BD = Hacl.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length
inline_for_extraction noextract
let salt_len_t (a:Hash.fixed_len_alg) =
saltLen:size_t{8 + Hash.hash_length a + v saltLen <= max_size_t /\ (8 + Hash.hash_length a + v saltLen) `less_than_max_input_length` a}
inline_for_extraction noextract
let msg_len_t (a:Hash.fixed_len_alg) =
msgLen:size_t{v msgLen `less_than_max_input_length` a}
inline_for_extraction noextract
let em_len_t (a:Hash.fixed_len_alg) (saltLen:salt_len_t a) =
emBits:size_t{0 < v emBits /\ Hash.hash_length a + v saltLen + 2 <= S.blocks (v emBits) 8}
inline_for_extraction noextract
val xor_bytes:
len:size_t{v len > 0}
-> b1:lbuffer uint8 len
-> b2:lbuffer uint8 len ->
Stack unit
(requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2)
(ensures fun h0 _ h1 -> modifies (loc b1) h0 h1 /\
as_seq h1 b1 == S.xor_bytes (as_seq h0 b1) (as_seq h0 b2))
let xor_bytes len b1 b2 =
map2T len b1 (fun x y -> x ^. y) b1 b2
inline_for_extraction noextract
val db_zero:
len:size_t{v len > 0}
-> db:lbuffer uint8 len
-> emBits:size_t ->
Stack unit
(requires fun h -> live h db)
(ensures fun h0 _ h1 -> modifies (loc db) h0 h1 /\
as_seq h1 db == S.db_zero #(v len) (as_seq h0 db) (v emBits))
let db_zero len db emBits =
let msBits = emBits %. 8ul in
if msBits >. 0ul then
db.(0ul) <- db.(0ul) &. (u8 0xff >>. (8ul -. msBits))
inline_for_extraction noextract
val get_m1Hash:
a:Hash.hash_alg{S.hash_is_supported a}
-> saltLen:salt_len_t a
-> salt:lbuffer uint8 saltLen
-> msgLen:msg_len_t a
-> msg:lbuffer uint8 msgLen
-> hLen:size_t{v hLen == Hash.hash_length a}
-> m1Hash:lbuffer uint8 hLen ->
Stack unit
(requires fun h ->
live h salt /\ live h msg /\ live h m1Hash /\
disjoint msg salt /\ disjoint m1Hash msg /\ disjoint m1Hash salt)
(ensures fun h0 _ h1 -> modifies (loc m1Hash) h0 h1 /\
(let mHash = Hash.hash a (as_seq h0 msg) in
let m1Len = 8 + Hash.hash_length a + v saltLen in
let m1 = LSeq.create m1Len (u8 0) in
let m1 = LSeq.update_sub m1 8 (Hash.hash_length a) mHash in
let m1 = LSeq.update_sub m1 (8 + Hash.hash_length a) (v saltLen) (as_seq h0 salt) in
as_seq h1 m1Hash == Hash.hash a m1))
let get_m1Hash a saltLen salt msgLen msg hLen m1Hash =
push_frame ();
//m1 = [8 * 0x00; mHash; salt]
let m1Len = 8ul +! hLen +! saltLen in
let m1 = create m1Len (u8 0) in
let h0 = ST.get () in
update_sub_f h0 m1 8ul hLen
(fun h -> Hash.hash a (as_seq h0 msg))
(fun _ -> hash a (sub m1 8ul hLen) msgLen msg);
update_sub m1 (8ul +! hLen) saltLen salt;
hash a m1Hash m1Len m1;
pop_frame()
inline_for_extraction noextract
val get_maskedDB:
a:Hash.hash_alg{S.hash_is_supported a}
-> saltLen:salt_len_t a
-> salt:lbuffer uint8 saltLen
-> hLen:size_t{v hLen == Hash.hash_length a}
-> m1Hash:lbuffer uint8 hLen
-> emBits:em_len_t a saltLen
-> dbLen:size_t{v dbLen == S.blocks (v emBits) 8 - Hash.hash_length a - 1}
-> db_mask:lbuffer uint8 dbLen ->
Stack unit
(requires fun h ->
live h salt /\ live h m1Hash /\ live h db_mask /\
disjoint m1Hash salt /\ disjoint m1Hash db_mask /\ disjoint db_mask salt /\
as_seq h db_mask == LSeq.create (v dbLen) (u8 0))
(ensures fun h0 _ h1 -> modifies (loc db_mask) h0 h1 /\
(let emLen = S.blocks (v emBits) 8 in
let dbLen = emLen - Hash.hash_length a - 1 in
let db = LSeq.create dbLen (u8 0) in
let last_before_salt = dbLen - v saltLen - 1 in
let db = LSeq.upd db last_before_salt (u8 1) in
let db = LSeq.update_sub db (last_before_salt + 1) (v saltLen) (as_seq h0 salt) in
let dbMask = S.mgf_hash a (v hLen) (as_seq h0 m1Hash) dbLen in
let maskedDB = S.xor_bytes db dbMask in
let maskedDB = S.db_zero maskedDB (v emBits) in
as_seq h1 db_mask == maskedDB))
let get_maskedDB a saltLen salt hLen m1Hash emBits dbLen db =
push_frame ();
//db = [0x00;..; 0x00; 0x01; salt]
let last_before_salt = dbLen -! saltLen -! 1ul in
db.(last_before_salt) <- u8 1;
update_sub db (last_before_salt +! 1ul) saltLen salt;
let dbMask = create dbLen (u8 0) in
assert_norm (Hash.hash_length a + 4 <= max_size_t /\ (Hash.hash_length a + 4) `less_than_max_input_length` a);
mgf_hash a hLen m1Hash dbLen dbMask;
xor_bytes dbLen db dbMask;
db_zero dbLen db emBits;
pop_frame()
val pss_encode:
a:Hash.hash_alg{S.hash_is_supported a}
-> saltLen:salt_len_t a
-> salt:lbuffer uint8 saltLen
-> msgLen:msg_len_t a
-> msg:lbuffer uint8 msgLen
-> emBits:em_len_t a saltLen
-> em:lbuffer uint8 (BD.blocks emBits 8ul) ->
Stack unit
(requires fun h ->
live h salt /\ live h msg /\ live h em /\
disjoint msg salt /\ disjoint em msg /\ disjoint em salt /\
as_seq h em == LSeq.create (S.blocks (v emBits) 8) (u8 0))
(ensures fun h0 _ h1 -> modifies (loc em) h0 h1 /\
as_seq h1 em == S.pss_encode a (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (v emBits))
[@CInline]
let pss_encode a saltLen salt msgLen msg emBits em =
push_frame ();
let hLen = hash_len a in
let m1Hash = create hLen (u8 0) in
get_m1Hash a saltLen salt msgLen msg hLen m1Hash;
let emLen = BD.blocks emBits 8ul in
let dbLen = emLen -! hLen -! 1ul in
let db = create dbLen (u8 0) in
get_maskedDB a saltLen salt hLen m1Hash emBits dbLen db;
update_sub em 0ul dbLen db;
update_sub em dbLen hLen m1Hash;
em.(emLen -! 1ul) <- u8 0xbc;
pop_frame()
inline_for_extraction noextract
val pss_verify_:
a:Hash.hash_alg{S.hash_is_supported a}
-> saltLen:salt_len_t a
-> msgLen:msg_len_t a
-> msg:lbuffer uint8 msgLen
-> emBits:em_len_t a saltLen
-> em:lbuffer uint8 (BD.blocks emBits 8ul) ->
Stack bool
(requires fun h -> live h msg /\ live h em /\ disjoint em msg)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.pss_verify_ a (v saltLen) (v msgLen) (as_seq h0 msg) (v emBits) (as_seq h0 em)) | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.Padding.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
saltLen: Hacl.Impl.RSAPSS.Padding.salt_len_t a ->
msgLen: Hacl.Impl.RSAPSS.Padding.msg_len_t a ->
msg: Lib.Buffer.lbuffer Lib.IntTypes.uint8 msgLen ->
emBits: Hacl.Impl.RSAPSS.Padding.em_len_t a saltLen ->
em: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Bignum.Definitions.blocks emBits 8ul)
-> FStar.HyperStack.ST.Stack Prims.bool | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Hacl.Impl.RSAPSS.Padding.salt_len_t",
"Hacl.Impl.RSAPSS.Padding.msg_len_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Impl.RSAPSS.Padding.em_len_t",
"Hacl.Bignum.Definitions.blocks",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.ByteBuffer.lbytes_eq",
"Hacl.Impl.RSAPSS.Padding.get_m1Hash",
"Prims.op_Negation",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Buffer.sub",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.op_Subtraction_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.u8",
"Lib.Buffer.create",
"Hacl.Impl.RSAPSS.Padding.db_zero",
"Hacl.Impl.RSAPSS.Padding.xor_bytes",
"Hacl.Impl.RSAPSS.MGF.mgf_hash",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Spec.Hash.Definitions.hash_length",
"Hacl.Impl.RSAPSS.MGF.hash_len",
"Prims.op_Multiply",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Hacl.Spec.Bignum.Definitions.blocks",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let pss_verify_ a saltLen msgLen msg emBits em =
| push_frame ();
let emLen = BD.blocks emBits 8ul in
let hLen = hash_len a in
let m1Hash0 = create hLen (u8 0) in
let dbLen = emLen -! hLen -! 1ul in
let maskedDB = sub em 0ul dbLen in
let m1Hash = sub em dbLen hLen in
let dbMask = create dbLen (u8 0) in
mgf_hash a hLen m1Hash dbLen dbMask;
xor_bytes dbLen dbMask maskedDB;
db_zero dbLen dbMask emBits;
let padLen = emLen -! saltLen -! hLen -! 1ul in
let pad2 = create padLen (u8 0) in
pad2.(padLen -! 1ul) <- u8 0x01;
let pad = sub dbMask 0ul padLen in
let salt = sub dbMask padLen saltLen in
let res =
if not (Lib.ByteBuffer.lbytes_eq #padLen pad pad2)
then false
else
(get_m1Hash a saltLen salt msgLen msg hLen m1Hash0;
Lib.ByteBuffer.lbytes_eq #hLen m1Hash0 m1Hash)
in
pop_frame ();
res | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_quads_to_block_be | val lemma_quads_to_block_be (qs:seq quad32) : Lemma
(requires length qs == 4)
(ensures
(let block = quads_to_block_be qs in
forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==>
(qs.[i]).hi3 == ws_opaque block (4 * i + 0) /\
(qs.[i]).hi2 == ws_opaque block (4 * i + 1) /\
(qs.[i]).lo1 == ws_opaque block (4 * i + 2) /\
(qs.[i]).lo0 == ws_opaque block (4 * i + 3))) | val lemma_quads_to_block_be (qs:seq quad32) : Lemma
(requires length qs == 4)
(ensures
(let block = quads_to_block_be qs in
forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==>
(qs.[i]).hi3 == ws_opaque block (4 * i + 0) /\
(qs.[i]).hi2 == ws_opaque block (4 * i + 1) /\
(qs.[i]).lo1 == ws_opaque block (4 * i + 2) /\
(qs.[i]).lo0 == ws_opaque block (4 * i + 3))) | let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 403,
"start_col": 0,
"start_line": 400
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal () | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | qs: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length qs == 4)
(ensures
(let block = Vale.SHA.PPC64LE.SHA_helpers.quads_to_block_be qs in
forall (i:
Prims.int
{ i >= 0 /\ i < FStar.Seq.Base.length qs /\ (i >= 0) /\ (i < FStar.Seq.Base.length qs) /\
(i >= 0) /\ (i < FStar.Seq.Base.length qs) /\
(i >= 0) /\ (i < FStar.Seq.Base.length qs) }).
{:pattern FStar.Seq.Base.index qs i}
0 <= i /\ i < 4 ==>
Mkfour?.hi3 qs.[ i ] == Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block (4 * i + 0) /\
Mkfour?.hi2 qs.[ i ] == Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block (4 * i + 1) /\
Mkfour?.lo1 qs.[ i ] == Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block (4 * i + 2) /\
Mkfour?.lo0 qs.[ i ] == Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block (4 * i + 3))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.block_w",
"Spec.SHA2.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.Hash.Definitions.word",
"Spec.SHA2.Lemmas.ws",
"Prims.unit",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat32",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Mul.op_Star",
"Vale.Def.Words.Seq_s.seq_four_to_seq_BE"
] | [] | true | false | true | false | false | let lemma_quads_to_block_be qs =
| reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws | false |
Ariadne.fst | Ariadne.saved | val saved: counter -> record -> Type0 | val saved: counter -> record -> Type0 | let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w)) | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 29,
"end_line": 71,
"start_col": 0,
"start_line": 60
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have. | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | _: Ariadne.counter -> s: Ariadne.record -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Ariadne.counter",
"Ariadne.record",
"Ariadne.index",
"Ariadne.case",
"Ariadne.state",
"Prims.l_or",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.l_and",
"Prims.op_Equality",
"Prims.logical",
"Prims.int",
"Prims.op_Addition",
"Prims.l_False"
] | [] | false | false | false | true | true | let saved (Counter n c) s =
| let m, u = s in
(m < n) \/
(m = n /\
(match c with
| Ok v -> u = v
| Recover w v | Writing w v | Crash w v -> u = w \/ u = v)) \/
(m = n + 1 /\
(match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u = v
| Crash v w -> u = v \/ u = w)) | false |
Ariadne.fst | Ariadne.log_pre | val log_pre (c: ctr) : preorder (list (backup c)) | val log_pre (c: ctr) : preorder (list (backup c)) | let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 60,
"end_line": 96,
"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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | c: Ariadne.ctr -> FStar.Preorder.preorder (Prims.list (Ariadne.backup c)) | Prims.Tot | [
"total"
] | [] | [
"Ariadne.ctr",
"Ariadne.log_pre'",
"FStar.Preorder.preorder",
"Prims.list",
"Ariadne.backup"
] | [] | false | false | false | false | false | let log_pre (c: ctr) : preorder (list (backup c)) =
| log_pre' c | false |
Ariadne.fst | Ariadne.step1 | val step1: c:case {pre1 c} -> case | val step1: c:case {pre1 c} -> case | let step1 = function
| Writing w v -> Ok w
| Crash v0 v1 -> Recover v0 v1 | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 163,
"start_col": 0,
"start_line": 161
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2
let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2
let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c
type log (c:ctr) = mref (list (backup c)) (log_pre c)
type key (c:ctr) = log c
// Private datatype constructor for modeling hardware protection; packaging
// the enclave capabilities to use the monotonic counter c and backup key k.
noeq type protected =
| Protect: c:ctr -> k:key c -> protected
val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v))
let create v =
let c = alloc (Counter 0 (Ok v)) in
let r = (0,v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k
// Privileged code calling back into fallible host code: this may
// fail, in which case we still conservatively assume the host gets
// the saved record (although we can't rely on it for recovery).
let pre0 c w =
match c with
| Ok u -> True
| Recover u v
| Writing u v
| Crash u v -> w==u \/ w==v
let step0 c w =
match c with
| Ok u -> Writing w u
| Recover u v -> if w=u then Writing u v else Crash w u
| Writing u v
| Crash u v -> if w=u then Crash w v else Crash w u
val save: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
pre0 c0 w)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter n c0 = sel h0 c in
pre0 c0 w /\ (
let c1 = step0 c0 w in
sel h1 c == Counter n c1))
let save p w =
let Protect c k = p in
let Counter n c0 = read c in
let c1 = step0 c0 w in
write c (Counter n c1);
let r = (n+1,w) in
witness (saved_backup c r);
let log0 = read k in
write k (r::log0)
// Incrementing the counter is privileged code;
// it may fail before or after incrementing c.
let pre1 c = Writing? c \/ Crash? c | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | c: Ariadne.case{Ariadne.pre1 c} -> Ariadne.case | Prims.Tot | [
"total"
] | [] | [
"Ariadne.case",
"Ariadne.pre1",
"Ariadne.state",
"Ariadne.Ok",
"Ariadne.Recover"
] | [] | false | false | false | false | false | let step1 =
| function
| Writing w v -> Ok w
| Crash v0 v1 -> Recover v0 v1 | false |
Ariadne.fst | Ariadne.save | val save: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
pre0 c0 w)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter n c0 = sel h0 c in
pre0 c0 w /\ (
let c1 = step0 c0 w in
sel h1 c == Counter n c1)) | val save: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
pre0 c0 w)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter n c0 = sel h0 c in
pre0 c0 w /\ (
let c1 = step0 c0 w in
sel h1 c == Counter n c1)) | let save p w =
let Protect c k = p in
let Counter n c0 = read c in
let c1 = step0 c0 w in
write c (Counter n c1);
let r = (n+1,w) in
witness (saved_backup c r);
let log0 = read k in
write k (r::log0) | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 19,
"end_line": 154,
"start_col": 0,
"start_line": 146
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2
let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2
let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c
type log (c:ctr) = mref (list (backup c)) (log_pre c)
type key (c:ctr) = log c
// Private datatype constructor for modeling hardware protection; packaging
// the enclave capabilities to use the monotonic counter c and backup key k.
noeq type protected =
| Protect: c:ctr -> k:key c -> protected
val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v))
let create v =
let c = alloc (Counter 0 (Ok v)) in
let r = (0,v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k
// Privileged code calling back into fallible host code: this may
// fail, in which case we still conservatively assume the host gets
// the saved record (although we can't rely on it for recovery).
let pre0 c w =
match c with
| Ok u -> True
| Recover u v
| Writing u v
| Crash u v -> w==u \/ w==v
let step0 c w =
match c with
| Ok u -> Writing w u
| Recover u v -> if w=u then Writing u v else Crash w u
| Writing u v
| Crash u v -> if w=u then Crash w v else Crash w u
val save: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
pre0 c0 w)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter n c0 = sel h0 c in
pre0 c0 w /\ (
let c1 = step0 c0 w in
sel h1 c == Counter n c1)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | p: Ariadne.protected -> w: Ariadne.state -> FStar.All.All Prims.unit | FStar.All.All | [] | [] | [
"Ariadne.protected",
"Ariadne.state",
"Ariadne.ctr",
"Ariadne.key",
"Ariadne.index",
"Ariadne.case",
"FStar.ST.write",
"Prims.list",
"Ariadne.backup",
"Ariadne.log_pre",
"Prims.Cons",
"Prims.unit",
"FStar.ST.read",
"FStar.MRef.witness",
"Ariadne.saved_backup",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_Addition",
"Ariadne.counter",
"Ariadne.preorder'",
"Ariadne.Counter",
"Ariadne.step0"
] | [] | false | true | false | false | false | let save p w =
| let Protect c k = p in
let Counter n c0 = read c in
let c1 = step0 c0 w in
write c (Counter n c1);
let r = (n + 1, w) in
witness (saved_backup c r);
let log0 = read k in
write k (r :: log0) | false |
Ariadne.fst | Ariadne.incr | val incr: c:ctr -> w:state -> All unit
(requires fun h0 ->
let Counter _ c0 = sel h0 c in
pre1 c0)
(ensures fun h0 r h1 ->
let v0 = sel h0 c in
let Counter n0 c0 = v0 in
pre1 c0 /\ (
let c1 = step1 c0 in
let v1 = Counter (n0+1) c1 in
match r with
| V _ -> sel h1 c == v1
| _ -> sel h1 c == v0 \/ sel h1 c == v1 )) | val incr: c:ctr -> w:state -> All unit
(requires fun h0 ->
let Counter _ c0 = sel h0 c in
pre1 c0)
(ensures fun h0 r h1 ->
let v0 = sel h0 c in
let Counter n0 c0 = v0 in
pre1 c0 /\ (
let c1 = step1 c0 in
let v1 = Counter (n0+1) c1 in
match r with
| V _ -> sel h1 c == v1
| _ -> sel h1 c == v0 \/ sel h1 c == v1 )) | let incr c w =
let x = read c in
let Counter n0 c0 = x in
if n0 = 3 then failwith "crash" else
write c (Counter (n0+1) (step1 c0)) | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 37,
"end_line": 184,
"start_col": 0,
"start_line": 180
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2
let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2
let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c
type log (c:ctr) = mref (list (backup c)) (log_pre c)
type key (c:ctr) = log c
// Private datatype constructor for modeling hardware protection; packaging
// the enclave capabilities to use the monotonic counter c and backup key k.
noeq type protected =
| Protect: c:ctr -> k:key c -> protected
val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v))
let create v =
let c = alloc (Counter 0 (Ok v)) in
let r = (0,v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k
// Privileged code calling back into fallible host code: this may
// fail, in which case we still conservatively assume the host gets
// the saved record (although we can't rely on it for recovery).
let pre0 c w =
match c with
| Ok u -> True
| Recover u v
| Writing u v
| Crash u v -> w==u \/ w==v
let step0 c w =
match c with
| Ok u -> Writing w u
| Recover u v -> if w=u then Writing u v else Crash w u
| Writing u v
| Crash u v -> if w=u then Crash w v else Crash w u
val save: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
pre0 c0 w)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter n c0 = sel h0 c in
pre0 c0 w /\ (
let c1 = step0 c0 w in
sel h1 c == Counter n c1))
let save p w =
let Protect c k = p in
let Counter n c0 = read c in
let c1 = step0 c0 w in
write c (Counter n c1);
let r = (n+1,w) in
witness (saved_backup c r);
let log0 = read k in
write k (r::log0)
// Incrementing the counter is privileged code;
// it may fail before or after incrementing c.
let pre1 c = Writing? c \/ Crash? c
val step1: c:case {pre1 c} -> case
let step1 = function
| Writing w v -> Ok w
| Crash v0 v1 -> Recover v0 v1
val incr: c:ctr -> w:state -> All unit
(requires fun h0 ->
let Counter _ c0 = sel h0 c in
pre1 c0)
(ensures fun h0 r h1 ->
let v0 = sel h0 c in
let Counter n0 c0 = v0 in
pre1 c0 /\ (
let c1 = step1 c0 in
let v1 = Counter (n0+1) c1 in
match r with
| V _ -> sel h1 c == v1
| _ -> sel h1 c == v0 \/ sel h1 c == v1 )) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | c: Ariadne.ctr -> w: Ariadne.state -> FStar.All.All Prims.unit | FStar.All.All | [] | [] | [
"Ariadne.ctr",
"Ariadne.state",
"Ariadne.index",
"Ariadne.case",
"Prims.op_Equality",
"Prims.int",
"FStar.All.failwith",
"Prims.unit",
"Prims.bool",
"FStar.ST.write",
"Ariadne.counter",
"Ariadne.preorder'",
"Ariadne.Counter",
"Prims.op_Addition",
"Ariadne.step1",
"FStar.ST.read"
] | [] | false | true | false | false | false | let incr c w =
| let x = read c in
let Counter n0 c0 = x in
if n0 = 3 then failwith "crash" else write c (Counter (n0 + 1) (step1 c0)) | false |
Ariadne.fst | Ariadne.saved_backup | val saved_backup (c: ctr) (s: record) : (f: (heap -> Type0){FStar.ST.stable f}) | val saved_backup (c: ctr) (s: record) : (f: (heap -> Type0){FStar.ST.stable f}) | let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 48,
"end_line": 88,
"start_col": 0,
"start_line": 87
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions. | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | c: Ariadne.ctr -> s: Ariadne.record -> f: (_: FStar.Monotonic.Heap.heap -> Type0){FStar.ST.stable f} | Prims.Tot | [
"total"
] | [] | [
"Ariadne.ctr",
"Ariadne.record",
"FStar.Monotonic.Heap.heap",
"Prims.l_and",
"FStar.Monotonic.Heap.contains",
"Ariadne.counter",
"Ariadne.preorder'",
"Ariadne.saved",
"FStar.Monotonic.Heap.sel",
"FStar.ST.stable"
] | [] | false | false | false | true | true | let saved_backup (c: ctr) (s: record) : (f: (heap -> Type0){FStar.ST.stable f}) =
| fun h -> h `contains` c /\ saved (sel h c) s | false |
Ariadne.fst | Ariadne.pre0 | val pre0 : c: Ariadne.case -> w: Ariadne.state -> Prims.logical | let pre0 c w =
match c with
| Ok u -> True
| Recover u v
| Writing u v
| Crash u v -> w==u \/ w==v | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 29,
"end_line": 126,
"start_col": 0,
"start_line": 121
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2
let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2
let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c
type log (c:ctr) = mref (list (backup c)) (log_pre c)
type key (c:ctr) = log c
// Private datatype constructor for modeling hardware protection; packaging
// the enclave capabilities to use the monotonic counter c and backup key k.
noeq type protected =
| Protect: c:ctr -> k:key c -> protected
val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v))
let create v =
let c = alloc (Counter 0 (Ok v)) in
let r = (0,v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k
// Privileged code calling back into fallible host code: this may
// fail, in which case we still conservatively assume the host gets
// the saved record (although we can't rely on it for recovery). | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | c: Ariadne.case -> w: Ariadne.state -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Ariadne.case",
"Ariadne.state",
"Prims.l_True",
"Prims.l_or",
"Prims.eq2",
"Prims.logical"
] | [] | false | false | false | true | true | let pre0 c w =
| match c with
| Ok u -> True
| Recover u v | Writing u v | Crash u v -> w == u \/ w == v | false |
|
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_add_mod_associates_U32 | val lemma_add_mod_associates_U32 (x y z: UInt32.t)
: Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z) | val lemma_add_mod_associates_U32 (x y z: UInt32.t)
: Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z) | let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z) | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 472,
"start_col": 0,
"start_line": 457
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ()
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
#reset-options "--z3rlimit 20"
let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in
let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in
word_to_nat32 h.[0] == add_wrap t1 t2 /\
word_to_nat32 h.[1] == a0 /\
word_to_nat32 h.[2] == b0 /\
word_to_nat32 h.[3] == c0 /\
word_to_nat32 h.[4] == add_wrap d0 t1 /\
word_to_nat32 h.[5] == e0 /\
word_to_nat32 h.[6] == f0 /\
word_to_nat32 h.[7] == g0))
=
let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
ch_256_reveal ();
maj_256_reveal ();
lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0);
lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t);
lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0));
lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t));
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig;
shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
() | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: FStar.UInt32.t -> y: FStar.UInt32.t -> z: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(ensures
FStar.UInt32.add_mod x (FStar.UInt32.add_mod y z) ==
FStar.UInt32.add_mod (FStar.UInt32.add_mod x y) z) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.UInt32.t",
"FStar.UInt32.v_inj",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"FStar.Calc.calc_finish",
"Lib.IntTypes.range_t",
"Prims.eq2",
"Lib.IntTypes.v",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Prims.op_Modulus",
"Prims.op_Addition",
"Prims.pow2",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_add_distr",
"Prims.l_True",
"FStar.UInt32.add_mod",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let lemma_add_mod_associates_U32 (x y z: UInt32.t)
: Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z) =
| let open Lib.IntTypes in
calc ( == ) {
v (x +. (y +. z));
( == ) { () }
(v x + (v y + v z) % pow2 32) % pow2 32;
( == ) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
( == ) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
( == ) { () }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z) | false |
Ariadne.fst | Ariadne.create | val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v)) | val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v)) | let create v =
let c = alloc (Counter 0 (Ok v)) in
let r = (0,v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 13,
"end_line": 115,
"start_col": 0,
"start_line": 110
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2
let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2
let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c
type log (c:ctr) = mref (list (backup c)) (log_pre c)
type key (c:ctr) = log c
// Private datatype constructor for modeling hardware protection; packaging
// the enclave capabilities to use the monotonic counter c and backup key k.
noeq type protected =
| Protect: c:ctr -> k:key c -> protected
val create: v: state -> ST protected
(requires fun h0 -> True) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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: Ariadne.state -> FStar.ST.ST Ariadne.protected | FStar.ST.ST | [] | [] | [
"Ariadne.state",
"Ariadne.Protect",
"Ariadne.protected",
"FStar.ST.mref",
"Prims.list",
"Ariadne.backup",
"Ariadne.log_pre",
"FStar.ST.alloc",
"Prims.Cons",
"Prims.Nil",
"Prims.unit",
"FStar.MRef.witness",
"Ariadne.saved_backup",
"FStar.Pervasives.Native.tuple2",
"Ariadne.index",
"FStar.Pervasives.Native.Mktuple2",
"Ariadne.counter",
"Ariadne.preorder'",
"Ariadne.Counter",
"Ariadne.Ok"
] | [] | false | true | false | false | false | let create v =
| let c = alloc (Counter 0 (Ok v)) in
let r = (0, v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k | false |
Ariadne.fst | Ariadne.preorder' | val preorder':preorder counter | val preorder':preorder counter | let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 102,
"end_line": 73,
"start_col": 0,
"start_line": 73
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Preorder.preorder Ariadne.counter | Prims.Tot | [
"total"
] | [] | [
"Ariadne.counter",
"Prims.l_Forall",
"Ariadne.record",
"Prims.l_imp",
"Ariadne.saved",
"Prims.logical"
] | [] | false | false | false | true | false | let preorder':preorder counter =
| fun (x0: counter) (x1: counter) -> forall s. saved x0 s ==> saved x1 s | false |
Ariadne.fst | Ariadne.step0 | val step0 : c: Ariadne.case -> w: Ariadne.state -> Ariadne.case | let step0 c w =
match c with
| Ok u -> Writing w u
| Recover u v -> if w=u then Writing u v else Crash w u
| Writing u v
| Crash u v -> if w=u then Crash w v else Crash w u | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 53,
"end_line": 132,
"start_col": 0,
"start_line": 127
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2
let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2
let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c
type log (c:ctr) = mref (list (backup c)) (log_pre c)
type key (c:ctr) = log c
// Private datatype constructor for modeling hardware protection; packaging
// the enclave capabilities to use the monotonic counter c and backup key k.
noeq type protected =
| Protect: c:ctr -> k:key c -> protected
val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v))
let create v =
let c = alloc (Counter 0 (Ok v)) in
let r = (0,v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k
// Privileged code calling back into fallible host code: this may
// fail, in which case we still conservatively assume the host gets
// the saved record (although we can't rely on it for recovery).
let pre0 c w =
match c with
| Ok u -> True
| Recover u v
| Writing u v | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | c: Ariadne.case -> w: Ariadne.state -> Ariadne.case | Prims.Tot | [
"total"
] | [] | [
"Ariadne.case",
"Ariadne.state",
"Ariadne.Writing",
"Prims.op_Equality",
"Prims.bool",
"Ariadne.Crash"
] | [] | false | false | false | true | false | let step0 c w =
| match c with
| Ok u -> Writing w u
| Recover u v -> if w = u then Writing u v else Crash w u
| Writing u v | Crash u v -> if w = u then Crash w v else Crash w u | false |
|
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_le_bytes_to_hash_quads | val lemma_le_bytes_to_hash_quads (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
(let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[ 0 ] == to_uint32 (s.[ 0 ]).lo0 /\ rhs.[ 1 ] == to_uint32 (s.[ 0 ]).lo1 /\
rhs.[ 2 ] == to_uint32 (s.[ 0 ]).hi2 /\ rhs.[ 3 ] == to_uint32 (s.[ 0 ]).hi3 /\
rhs.[ 4 ] == to_uint32 (s.[ 1 ]).lo0 /\ rhs.[ 5 ] == to_uint32 (s.[ 1 ]).lo1 /\
rhs.[ 6 ] == to_uint32 (s.[ 1 ]).hi2 /\ rhs.[ 7 ] == to_uint32 (s.[ 1 ]).hi3 /\
length rhs == 8)) | val lemma_le_bytes_to_hash_quads (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
(let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[ 0 ] == to_uint32 (s.[ 0 ]).lo0 /\ rhs.[ 1 ] == to_uint32 (s.[ 0 ]).lo1 /\
rhs.[ 2 ] == to_uint32 (s.[ 0 ]).hi2 /\ rhs.[ 3 ] == to_uint32 (s.[ 0 ]).hi3 /\
rhs.[ 4 ] == to_uint32 (s.[ 1 ]).lo0 /\ rhs.[ 5 ] == to_uint32 (s.[ 1 ]).lo1 /\
rhs.[ 6 ] == to_uint32 (s.[ 1 ]).hi2 /\ rhs.[ 7 ] == to_uint32 (s.[ 1 ]).hi3 /\
length rhs == 8)) | let lemma_le_bytes_to_hash_quads (s:seq quad32) : Lemma
(requires length s == 2)
(ensures (let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[0] == to_uint32 (s.[0]).lo0 /\
rhs.[1] == to_uint32 (s.[0]).lo1 /\
rhs.[2] == to_uint32 (s.[0]).hi2 /\
rhs.[3] == to_uint32 (s.[0]).hi3 /\
rhs.[4] == to_uint32 (s.[1]).lo0 /\
rhs.[5] == to_uint32 (s.[1]).lo1 /\
rhs.[6] == to_uint32 (s.[1]).hi2 /\
rhs.[7] == to_uint32 (s.[1]).hi3 /\
length rhs == 8))
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
lemma_le_bytes_to_hash_quads_part1 s;
assert (rhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s));
() | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 684,
"start_col": 0,
"start_line": 667
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ()
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
#reset-options "--z3rlimit 20"
let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in
let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in
word_to_nat32 h.[0] == add_wrap t1 t2 /\
word_to_nat32 h.[1] == a0 /\
word_to_nat32 h.[2] == b0 /\
word_to_nat32 h.[3] == c0 /\
word_to_nat32 h.[4] == add_wrap d0 t1 /\
word_to_nat32 h.[5] == e0 /\
word_to_nat32 h.[6] == f0 /\
word_to_nat32 h.[7] == g0))
=
let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
ch_256_reveal ();
maj_256_reveal ();
lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0);
lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t);
lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0));
lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t));
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig;
shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
#reset-options "--fuel 1 --z3rlimit 50"
let lemma_ws_opaque (block:block_w) (t:counter) : Lemma
(requires 16 <= t && t < size_k_w_256)
(ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16))))
=
let t16 = ws SHA2_256 block (t - 16) in
let t15 = ws SHA2_256 block (t - 15) in
let t7 = ws SHA2_256 block (t - 7) in
let t2 = ws SHA2_256 block (t - 2) in
let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
calc (==) {
ws_opaque block t;
(==) { Pervasives.reveal_opaque (`%ws) ws }
vv ((s1 +. t7 +. s0) +. t16);
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7 +. s0)) (ws_opaque block (t-16)) }
add_wrap (vv ((s1 +. t7) +. s0)) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7)) sigma0 }
add_wrap (add_wrap (vv (s1 +. t7)) sigma0) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod sigma1 (ws_opaque block (t-7)) }
add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16));
}
#reset-options "--fuel 0 --ifuel 0 --z3rlimit 20"
let translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old:quad32) : Lemma
(requires a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old)
(ensures (
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
let update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a b c d e f g h ==
repeat_range_vale_64 block hash_orig /\
a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old))
(ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block))
=
let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec r (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
r (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
r 64;
translate_hash_update a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_seperated_hash_quad32 a' b' c' d' e' f' g' h') (update_block hash_orig block));
()
#push-options "--max_fuel 1"
let lemma_slice_commutes_reverse_bytes_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_quad32_seq s) 0 pivot == reverse_bytes_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_quad32_seq s in
let srs = slice (reverse_bytes_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
=
let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
lemma_slice_commutes_reverse_bytes_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_quad32_seq s) 0 (bound + 4));
if bound = 0 then ()
else (
let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()
)
#pop-options
#push-options "--max_fuel 1"
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block_be qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
#pop-options
let lemma_le_bytes_to_hash_quads_part1 (s:seq quad32) : Lemma
(requires length s == 2)
(ensures le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s))
=
let lhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
assert (lhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)));
le_seq_quad32_to_bytes_reveal ();
Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s);
() | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length s == 2)
(ensures
(let rhs =
Vale.SHA.PPC64LE.SHA_helpers.le_bytes_to_hash (Vale.Def.Types_s.le_seq_quad32_to_bytes s
)
in
rhs.[ 0 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.lo0 s.[ 0 ]) /\
rhs.[ 1 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.lo1 s.[ 0 ]) /\
rhs.[ 2 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi2 s.[ 0 ]) /\
rhs.[ 3 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi3 s.[ 0 ]) /\
rhs.[ 4 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.lo0 s.[ 1 ]) /\
rhs.[ 5 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.lo1 s.[ 1 ]) /\
rhs.[ 6 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi2 s.[ 1 ]) /\
rhs.[ 7 ] == Vale.SHA.PPC64LE.SHA_helpers.to_uint32 (Mkfour?.hi3 s.[ 1 ]) /\
FStar.Seq.Base.length rhs == 8)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Vale.Lib.Seqs_s.seq_map",
"Vale.Def.Types_s.nat32",
"Vale.SHA.PPC64LE.SHA_helpers.nat32_to_word",
"Vale.Def.Words.Seq_s.seq_four_to_seq_LE",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_le_bytes_to_hash_quads_part1",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Vale.SHA.PPC64LE.SHA_helpers.le_bytes_to_hash",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"FStar.Pervasives.reveal_opaque",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat32",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Mul.op_Star",
"Prims.squash",
"Prims.l_and",
"Lib.IntTypes.uint32",
"Spec.SHA2.op_String_Access",
"Vale.SHA.PPC64LE.SHA_helpers.to_uint32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_le_bytes_to_hash_quads (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
(let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[ 0 ] == to_uint32 (s.[ 0 ]).lo0 /\ rhs.[ 1 ] == to_uint32 (s.[ 0 ]).lo1 /\
rhs.[ 2 ] == to_uint32 (s.[ 0 ]).hi2 /\ rhs.[ 3 ] == to_uint32 (s.[ 0 ]).hi3 /\
rhs.[ 4 ] == to_uint32 (s.[ 1 ]).lo0 /\ rhs.[ 5 ] == to_uint32 (s.[ 1 ]).lo1 /\
rhs.[ 6 ] == to_uint32 (s.[ 1 ]).hi2 /\ rhs.[ 7 ] == to_uint32 (s.[ 1 ]).hi3 /\
length rhs == 8)) =
| reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
lemma_le_bytes_to_hash_quads_part1 s;
assert (rhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s));
() | false |
Ariadne.fst | Ariadne.store | val store: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
Ok? c0)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter _ c1 = sel h1 c in
V? r ==> c1 = Ok w) | val store: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
Ok? c0)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter _ c1 = sel h1 c in
V? r ==> c1 = Ok w) | let store p w =
let Protect c _ = p in
save p w;
incr c w | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 10,
"end_line": 200,
"start_col": 0,
"start_line": 197
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2
let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2
let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c
type log (c:ctr) = mref (list (backup c)) (log_pre c)
type key (c:ctr) = log c
// Private datatype constructor for modeling hardware protection; packaging
// the enclave capabilities to use the monotonic counter c and backup key k.
noeq type protected =
| Protect: c:ctr -> k:key c -> protected
val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v))
let create v =
let c = alloc (Counter 0 (Ok v)) in
let r = (0,v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k
// Privileged code calling back into fallible host code: this may
// fail, in which case we still conservatively assume the host gets
// the saved record (although we can't rely on it for recovery).
let pre0 c w =
match c with
| Ok u -> True
| Recover u v
| Writing u v
| Crash u v -> w==u \/ w==v
let step0 c w =
match c with
| Ok u -> Writing w u
| Recover u v -> if w=u then Writing u v else Crash w u
| Writing u v
| Crash u v -> if w=u then Crash w v else Crash w u
val save: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
pre0 c0 w)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter n c0 = sel h0 c in
pre0 c0 w /\ (
let c1 = step0 c0 w in
sel h1 c == Counter n c1))
let save p w =
let Protect c k = p in
let Counter n c0 = read c in
let c1 = step0 c0 w in
write c (Counter n c1);
let r = (n+1,w) in
witness (saved_backup c r);
let log0 = read k in
write k (r::log0)
// Incrementing the counter is privileged code;
// it may fail before or after incrementing c.
let pre1 c = Writing? c \/ Crash? c
val step1: c:case {pre1 c} -> case
let step1 = function
| Writing w v -> Ok w
| Crash v0 v1 -> Recover v0 v1
val incr: c:ctr -> w:state -> All unit
(requires fun h0 ->
let Counter _ c0 = sel h0 c in
pre1 c0)
(ensures fun h0 r h1 ->
let v0 = sel h0 c in
let Counter n0 c0 = v0 in
pre1 c0 /\ (
let c1 = step1 c0 in
let v1 = Counter (n0+1) c1 in
match r with
| V _ -> sel h1 c == v1
| _ -> sel h1 c == v0 \/ sel h1 c == v1 ))
// A sample implementation of incr, with a sample failure.
let incr c w =
let x = read c in
let Counter n0 c0 = x in
if n0 = 3 then failwith "crash" else
write c (Counter (n0+1) (step1 c0))
// Storing a backup; requires a clean state.
val store: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
Ok? c0)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter _ c1 = sel h1 c in
V? r ==> c1 = Ok w) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | p: Ariadne.protected -> w: Ariadne.state -> FStar.All.All Prims.unit | FStar.All.All | [] | [] | [
"Ariadne.protected",
"Ariadne.state",
"Ariadne.ctr",
"Ariadne.key",
"Ariadne.incr",
"Prims.unit",
"Ariadne.save"
] | [] | false | true | false | false | false | let store p w =
| let Protect c _ = p in
save p w;
incr c w | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_ws_opaque | val lemma_ws_opaque (block:block_w) (t:counter) : Lemma
(requires 16 <= t && t < size_k_w_256)
(ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16)))) | val lemma_ws_opaque (block:block_w) (t:counter) : Lemma
(requires 16 <= t && t < size_k_w_256)
(ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16)))) | let lemma_ws_opaque (block:block_w) (t:counter) : Lemma
(requires 16 <= t && t < size_k_w_256)
(ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16))))
=
let t16 = ws SHA2_256 block (t - 16) in
let t15 = ws SHA2_256 block (t - 15) in
let t7 = ws SHA2_256 block (t - 7) in
let t2 = ws SHA2_256 block (t - 2) in
let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
calc (==) {
ws_opaque block t;
(==) { Pervasives.reveal_opaque (`%ws) ws }
vv ((s1 +. t7 +. s0) +. t16);
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7 +. s0)) (ws_opaque block (t-16)) }
add_wrap (vv ((s1 +. t7) +. s0)) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7)) sigma0 }
add_wrap (add_wrap (vv (s1 +. t7)) sigma0) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod sigma1 (ws_opaque block (t-7)) }
add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16));
} | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 519,
"start_col": 0,
"start_line": 494
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ()
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
#reset-options "--z3rlimit 20"
let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in
let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in
word_to_nat32 h.[0] == add_wrap t1 t2 /\
word_to_nat32 h.[1] == a0 /\
word_to_nat32 h.[2] == b0 /\
word_to_nat32 h.[3] == c0 /\
word_to_nat32 h.[4] == add_wrap d0 t1 /\
word_to_nat32 h.[5] == e0 /\
word_to_nat32 h.[6] == f0 /\
word_to_nat32 h.[7] == g0))
=
let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
ch_256_reveal ();
maj_256_reveal ();
lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0);
lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t);
lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0));
lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t));
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig;
shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
} | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | block: Vale.SHA.PPC64LE.SHA_helpers.block_w -> t: Vale.SHA.PPC64LE.SHA_helpers.counter
-> FStar.Pervasives.Lemma (requires 16 <= t && t < Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256)
(ensures
(let sigma0 =
Vale.SHA2.Wrapper.sigma256_0_0 (Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block (t - 15))
in
let sigma1 =
Vale.SHA2.Wrapper.sigma256_0_1 (Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block (t - 2))
in
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block t ==
Vale.Def.Types_s.add_wrap (Vale.Def.Types_s.add_wrap (Vale.Def.Types_s.add_wrap sigma1
(Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block (t - 7)))
sigma0)
(Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block (t - 16)))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.SHA.PPC64LE.SHA_helpers.block_w",
"Vale.SHA.PPC64LE.SHA_helpers.counter",
"FStar.Calc.calc_finish",
"Vale.Def.Words_s.nat32",
"Prims.eq2",
"Vale.SHA.PPC64LE.SHA_helpers.ws_opaque",
"Vale.Def.Types_s.add_wrap",
"Vale.Def.Words_s.pow2_32",
"Prims.op_Subtraction",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Vale.SHA.PPC64LE.SHA_helpers.vv",
"Spec.SHA2.op_Plus_Dot",
"Spec.Hash.Definitions.SHA2_256",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.block_w",
"Spec.SHA2.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.Hash.Definitions.word",
"Spec.SHA2.Lemmas.ws",
"Prims.squash",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_add_wrap_is_add_mod",
"Spec.SHA2._sigma0",
"Spec.SHA2._sigma1",
"Vale.SHA2.Wrapper.sigma256_0_1",
"Vale.SHA2.Wrapper.sigma256_0_0",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256",
"Vale.Def.Words_s.natN",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let lemma_ws_opaque (block: block_w) (t: counter)
: Lemma (requires 16 <= t && t < size_k_w_256)
(ensures
(let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t ==
add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0)
(ws_opaque block (t - 16)))) =
| let t16 = ws SHA2_256 block (t - 16) in
let t15 = ws SHA2_256 block (t - 15) in
let t7 = ws SHA2_256 block (t - 7) in
let t2 = ws SHA2_256 block (t - 2) in
let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
calc ( == ) {
ws_opaque block t;
( == ) { Pervasives.reveal_opaque (`%ws) ws }
vv ((s1 +. t7 +. s0) +. t16);
( == ) { lemma_add_wrap_is_add_mod (vv (s1 +. t7 +. s0)) (ws_opaque block (t - 16)) }
add_wrap (vv ((s1 +. t7) +. s0)) (ws_opaque block (t - 16));
( == ) { lemma_add_wrap_is_add_mod (vv (s1 +. t7)) sigma0 }
add_wrap (add_wrap (vv (s1 +. t7)) sigma0) (ws_opaque block (t - 16));
( == ) { lemma_add_wrap_is_add_mod sigma1 (ws_opaque block (t - 7)) }
add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16));
} | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.shuffle_core_properties | val shuffle_core_properties (block: block_w) (hash: hash256) (t: counter{t < size_k_w_256})
: Lemma
(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[ t ] +.
(ws SHA2_256 block t)
in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[ 0 ] == t1 +. t2 /\ h.[ 1 ] == a0 /\ h.[ 2 ] == b0 /\ h.[ 3 ] == c0 /\ h.[ 4 ] == d0 +. t1 /\
h.[ 5 ] == e0 /\ h.[ 6 ] == f0 /\ h.[ 7 ] == g0) | val shuffle_core_properties (block: block_w) (hash: hash256) (t: counter{t < size_k_w_256})
: Lemma
(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[ t ] +.
(ws SHA2_256 block t)
in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[ 0 ] == t1 +. t2 /\ h.[ 1 ] == a0 /\ h.[ 2 ] == b0 /\ h.[ 3 ] == c0 /\ h.[ 4 ] == d0 +. t1 /\
h.[ 5 ] == e0 /\ h.[ 6 ] == f0 /\ h.[ 7 ] == g0) | let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
() | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 124,
"start_col": 0,
"start_line": 87
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
block: Vale.SHA.PPC64LE.SHA_helpers.block_w ->
hash: Vale.SHA.PPC64LE.SHA_helpers.hash256 ->
t: Vale.SHA.PPC64LE.SHA_helpers.counter{t < Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256}
-> FStar.Pervasives.Lemma
(ensures
(let h = Vale.SHA.PPC64LE.SHA_helpers.shuffle_core_opaque block hash t in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. Spec.SHA2._Sigma1 Spec.Hash.Definitions.SHA2_256 e0 +.
Spec.SHA2._Ch Spec.Hash.Definitions.SHA2_256 e0 f0 g0 +.
(Spec.SHA2.k0 Spec.Hash.Definitions.SHA2_256).[ t ] +.
Spec.SHA2.Lemmas.ws Spec.Hash.Definitions.SHA2_256 block t
in
let t2 =
Spec.SHA2._Sigma0 Spec.Hash.Definitions.SHA2_256 a0 +.
Spec.SHA2._Maj Spec.Hash.Definitions.SHA2_256 a0 b0 c0
in
h.[ 0 ] == t1 +. t2 /\ h.[ 1 ] == a0 /\ h.[ 2 ] == b0 /\ h.[ 3 ] == c0 /\
h.[ 4 ] == d0 +. t1 /\ h.[ 5 ] == e0 /\ h.[ 6 ] == f0 /\ h.[ 7 ] == g0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.SHA.PPC64LE.SHA_helpers.block_w",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Vale.SHA.PPC64LE.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256",
"Prims.unit",
"FStar.Seq.Properties.elim_of_list",
"FStar.UInt32.t",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.l_or",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Seq.Base.length",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Spec.Hash.Definitions.state_word_length",
"FStar.Seq.Base.seq_of_list",
"Prims.list",
"Prims.Cons",
"Spec.SHA2.op_Plus_Dot",
"Prims.Nil",
"Spec.SHA2._Sigma0",
"Spec.SHA2._Maj",
"Spec.SHA2._Sigma1",
"Spec.SHA2._Ch",
"Spec.SHA2.op_String_Access",
"Spec.SHA2.k0",
"Spec.SHA2.Lemmas.ws",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Spec.Hash.Definitions.words_state",
"Spec.SHA2.Lemmas.shuffle_core",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.block_w",
"Spec.SHA2.counter",
"Spec.SHA2.size_k_w",
"Prims.l_True",
"Prims.squash",
"Prims.l_and",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Vale.SHA.PPC64LE.SHA_helpers.shuffle_core_opaque",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let shuffle_core_properties (block: block_w) (hash: hash256) (t: counter{t < size_k_w_256})
: Lemma
(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[ t ] +.
(ws SHA2_256 block t)
in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[ 0 ] == t1 +. t2 /\ h.[ 1 ] == a0 /\ h.[ 2 ] == b0 /\ h.[ 3 ] == c0 /\ h.[ 4 ] == d0 +. t1 /\
h.[ 5 ] == e0 /\ h.[ 6 ] == f0 /\ h.[ 7 ] == g0) =
| Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[ t ] +.
(ws SHA2_256 block t)
in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0] in
assert (h == seq_of_list l);
elim_of_list l;
() | false |
Ariadne.fst | Ariadne.recover | val recover: p:protected -> last_saved:backup (Protect?.c p) -> All (option state)
(requires fun h0 -> True)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
let Counter _ c1 = sel h1 c in
match r with
| V None -> h0 == h1
| V (Some w1) -> (
c1 == Ok w1 /\
(match c0 with
| Ok w0 -> w1 = w0
| Writing v0 v0' | Recover v0 v0' | Crash v0 v0' -> w1 = v0 \/ w1 = v0' ))
| _ -> True
) | val recover: p:protected -> last_saved:backup (Protect?.c p) -> All (option state)
(requires fun h0 -> True)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
let Counter _ c1 = sel h1 c in
match r with
| V None -> h0 == h1
| V (Some w1) -> (
c1 == Ok w1 /\
(match c0 with
| Ok w0 -> w1 = w0
| Writing v0 v0' | Recover v0 v0' | Crash v0 v0' -> w1 = v0 \/ w1 = v0' ))
| _ -> True
) | let recover p last_saved =
let Protect c _ = p in
let m, w = last_saved in
let Counter n c0 = read c in
if m = n // authenticated decryption (see earlier comments on backup keys)
then (
recall (saved_backup c last_saved);
save p w;
incr c w;
save p w;
incr c w;
Some w)
else None | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 11,
"end_line": 232,
"start_col": 0,
"start_line": 220
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2
let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2
let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c
type log (c:ctr) = mref (list (backup c)) (log_pre c)
type key (c:ctr) = log c
// Private datatype constructor for modeling hardware protection; packaging
// the enclave capabilities to use the monotonic counter c and backup key k.
noeq type protected =
| Protect: c:ctr -> k:key c -> protected
val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v))
let create v =
let c = alloc (Counter 0 (Ok v)) in
let r = (0,v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k
// Privileged code calling back into fallible host code: this may
// fail, in which case we still conservatively assume the host gets
// the saved record (although we can't rely on it for recovery).
let pre0 c w =
match c with
| Ok u -> True
| Recover u v
| Writing u v
| Crash u v -> w==u \/ w==v
let step0 c w =
match c with
| Ok u -> Writing w u
| Recover u v -> if w=u then Writing u v else Crash w u
| Writing u v
| Crash u v -> if w=u then Crash w v else Crash w u
val save: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
pre0 c0 w)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter n c0 = sel h0 c in
pre0 c0 w /\ (
let c1 = step0 c0 w in
sel h1 c == Counter n c1))
let save p w =
let Protect c k = p in
let Counter n c0 = read c in
let c1 = step0 c0 w in
write c (Counter n c1);
let r = (n+1,w) in
witness (saved_backup c r);
let log0 = read k in
write k (r::log0)
// Incrementing the counter is privileged code;
// it may fail before or after incrementing c.
let pre1 c = Writing? c \/ Crash? c
val step1: c:case {pre1 c} -> case
let step1 = function
| Writing w v -> Ok w
| Crash v0 v1 -> Recover v0 v1
val incr: c:ctr -> w:state -> All unit
(requires fun h0 ->
let Counter _ c0 = sel h0 c in
pre1 c0)
(ensures fun h0 r h1 ->
let v0 = sel h0 c in
let Counter n0 c0 = v0 in
pre1 c0 /\ (
let c1 = step1 c0 in
let v1 = Counter (n0+1) c1 in
match r with
| V _ -> sel h1 c == v1
| _ -> sel h1 c == v0 \/ sel h1 c == v1 ))
// A sample implementation of incr, with a sample failure.
let incr c w =
let x = read c in
let Counter n0 c0 = x in
if n0 = 3 then failwith "crash" else
write c (Counter (n0+1) (step1 c0))
// Storing a backup; requires a clean state.
val store: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
Ok? c0)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter _ c1 = sel h1 c in
V? r ==> c1 = Ok w)
let store p w =
let Protect c _ = p in
save p w;
incr c w
// Recovering the state from a backuo; does not need *any*
// precondition, and leads to an Ok state (unless it crashes).
val recover: p:protected -> last_saved:backup (Protect?.c p) -> All (option state)
(requires fun h0 -> True)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
let Counter _ c1 = sel h1 c in
match r with
| V None -> h0 == h1
| V (Some w1) -> (
c1 == Ok w1 /\
(match c0 with
| Ok w0 -> w1 = w0
| Writing v0 v0' | Recover v0 v0' | Crash v0 v0' -> w1 = v0 \/ w1 = v0' ))
| _ -> True
) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | p: Ariadne.protected -> last_saved: Ariadne.backup (Protect?.c p)
-> FStar.All.All (FStar.Pervasives.Native.option Ariadne.state) | FStar.All.All | [] | [] | [
"Ariadne.protected",
"Ariadne.backup",
"Ariadne.__proj__Protect__item__c",
"Ariadne.ctr",
"Ariadne.key",
"Ariadne.index",
"Ariadne.state",
"Ariadne.case",
"Prims.op_Equality",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.option",
"Prims.unit",
"Ariadne.incr",
"Ariadne.save",
"FStar.MRef.recall",
"Ariadne.saved_backup",
"Prims.bool",
"FStar.Pervasives.Native.None",
"Ariadne.counter",
"FStar.ST.read",
"Ariadne.preorder'"
] | [] | false | true | false | false | false | let recover p last_saved =
| let Protect c _ = p in
let m, w = last_saved in
let Counter n c0 = read c in
if m = n
then
(recall (saved_backup c last_saved);
save p w;
incr c w;
save p w;
incr c w;
Some w)
else None | false |
Ariadne.fst | Ariadne.example | val example: trivial (trivial ctr) | val example: trivial (trivial ctr) | let example attack =
let p = create "hello" in
let Protect c k = p in
store p "world";
attack c;
match read k with
| r::_ ->
(match recover p r with
| Some _ -> store p "!\n"
| _ -> ())
| _ -> () | {
"file_name": "examples/preorders/Ariadne.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 9,
"end_line": 248,
"start_col": 0,
"start_line": 238
} | (*
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 Ariadne
// CF: We model the Ariadne protocol for state continuity.
// https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_strackx.pdf
//
// The protocol ensures that, as the SGX enclave gets stopped or
// its machine crashes, it can be reliably resumed in its last saved
// state. The protocol relies on
// - a trusted monotonic counter (implemented in hardware, intuitively expensive to increment)
// - a trusted fixed key (also implemented in hardware, used for authenticated encryption)
// - an untrusted but reliable store on the host, to save encrypted counters & states
open FStar.Preorder
open FStar.List.Tot
open FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to
// use the combination of state and exceptions (MSTMSTExn in the paper)
open FStar.Heap
open FStar.ST
open FStar.MRef
type index = nat // counter values (no overflow detection yet)
type state = string // the type of the enclave state; reset on crash.
type record = index * state // the type of backup records protected by authenticated encryption
// A small ghost state machine we use to capture the intermediate steps in the protocol.
type case =
| Ok: saved: state -> case
| Recover: read: state -> other: state -> case
| Writing: written: state -> old: state -> case
| Crash: read: state -> other: state -> case
// Packaging the hardware-based counter with a ghost state machine.
type counter =
| Counter:
n: index -> // counter (monotonic)
c: case -> // ghost state of the counter
counter
// A monotonic over-approximation of the encrypted backup records the host may have.
val saved: counter -> record -> Type0
let saved (Counter n c) s =
let m,u = s in
(m < n) \/ // an old state; authentication of m will fail, so nothing to say about it
(m = n /\ (match c with
| Ok v -> u=v
| Recover w v
| Writing w v
| Crash w v -> u=w \/ u=v)) \/
(m = n+1 /\ (match c with
| Ok _ | Recover _ _ -> False
| Writing v _ -> u=v
| Crash v w -> u=v \/ u=w))
let preorder' :preorder counter = fun (x0:counter) (x1:counter) -> forall s. saved x0 s ==> saved x1 s
// A monotonic view of the hardware-based counter.
type ctr = mref counter preorder'
// An encrypted backup, maintained by the host, and protected by a
// hardware-based encryption key. Compared to the general situation
// described in the POPL'18 paper, for simplicity and in order to
// focus on the state continuity property of Ariadne, we consider here
// only trivial backup keys, i.e., key c = unit * log c ≡ log c, where
// log c is the type of monotonic ghost logs of previously saved backups
// we attach to backup every key. As a result, in the following we
// also omit the authenticated encryption and decryption functions.
let saved_backup (c:ctr) (s:record) : (f:(heap -> Type0){FStar.ST.stable f}) =
fun h -> h `contains` c /\ saved (sel h c) s
type backup (c:ctr) = s:record{witnessed (saved_backup c s)}
let suffix_of (#c:ctr) (l1:list (backup c)) (l2:list (backup c)) =
l1 == l2 \/ strict_suffix_of l1 l2
let log_pre' (c:ctr) :relation (list (backup c)) = fun l1 l2 -> l1 `suffix_of` l2
let log_pre (c:ctr) :preorder (list (backup c)) = log_pre' c
type log (c:ctr) = mref (list (backup c)) (log_pre c)
type key (c:ctr) = log c
// Private datatype constructor for modeling hardware protection; packaging
// the enclave capabilities to use the monotonic counter c and backup key k.
noeq type protected =
| Protect: c:ctr -> k:key c -> protected
val create: v: state -> ST protected
(requires fun h0 -> True)
(ensures fun h0 (Protect c _) h1 -> sel h1 c == Counter 0 (Ok v))
let create v =
let c = alloc (Counter 0 (Ok v)) in
let r = (0,v) in
witness (saved_backup c r);
let k = alloc [r] in
Protect c k
// Privileged code calling back into fallible host code: this may
// fail, in which case we still conservatively assume the host gets
// the saved record (although we can't rely on it for recovery).
let pre0 c w =
match c with
| Ok u -> True
| Recover u v
| Writing u v
| Crash u v -> w==u \/ w==v
let step0 c w =
match c with
| Ok u -> Writing w u
| Recover u v -> if w=u then Writing u v else Crash w u
| Writing u v
| Crash u v -> if w=u then Crash w v else Crash w u
val save: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
pre0 c0 w)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter n c0 = sel h0 c in
pre0 c0 w /\ (
let c1 = step0 c0 w in
sel h1 c == Counter n c1))
let save p w =
let Protect c k = p in
let Counter n c0 = read c in
let c1 = step0 c0 w in
write c (Counter n c1);
let r = (n+1,w) in
witness (saved_backup c r);
let log0 = read k in
write k (r::log0)
// Incrementing the counter is privileged code;
// it may fail before or after incrementing c.
let pre1 c = Writing? c \/ Crash? c
val step1: c:case {pre1 c} -> case
let step1 = function
| Writing w v -> Ok w
| Crash v0 v1 -> Recover v0 v1
val incr: c:ctr -> w:state -> All unit
(requires fun h0 ->
let Counter _ c0 = sel h0 c in
pre1 c0)
(ensures fun h0 r h1 ->
let v0 = sel h0 c in
let Counter n0 c0 = v0 in
pre1 c0 /\ (
let c1 = step1 c0 in
let v1 = Counter (n0+1) c1 in
match r with
| V _ -> sel h1 c == v1
| _ -> sel h1 c == v0 \/ sel h1 c == v1 ))
// A sample implementation of incr, with a sample failure.
let incr c w =
let x = read c in
let Counter n0 c0 = x in
if n0 = 3 then failwith "crash" else
write c (Counter (n0+1) (step1 c0))
// Storing a backup; requires a clean state.
val store: p:protected -> w:state -> All unit
(requires fun h0 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
Ok? c0)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter _ c1 = sel h1 c in
V? r ==> c1 = Ok w)
let store p w =
let Protect c _ = p in
save p w;
incr c w
// Recovering the state from a backuo; does not need *any*
// precondition, and leads to an Ok state (unless it crashes).
val recover: p:protected -> last_saved:backup (Protect?.c p) -> All (option state)
(requires fun h0 -> True)
(ensures fun h0 r h1 ->
let Protect c _ = p in
let Counter _ c0 = sel h0 c in
let Counter _ c1 = sel h1 c in
match r with
| V None -> h0 == h1
| V (Some w1) -> (
c1 == Ok w1 /\
(match c0 with
| Ok w0 -> w1 = w0
| Writing v0 v0' | Recover v0 v0' | Crash v0 v0' -> w1 = v0 \/ w1 = v0' ))
| _ -> True
)
let recover p last_saved =
let Protect c _ = p in
let m, w = last_saved in
let Counter n c0 = read c in
if m = n // authenticated decryption (see earlier comments on backup keys)
then (
recall (saved_backup c last_saved);
save p w;
incr c w;
save p w;
incr c w;
Some w)
else None
// A test attack on the protocol.
type trivial 'a = 'a -> All unit (requires fun h0 -> True) (ensures fun h0 _ h1 -> True) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.ST.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MRef.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Heap.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Ariadne.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.All // Compared to the accompanying POPL'18 paper, we use F*'s All effect to",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.MRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": 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 | Ariadne.trivial (Ariadne.trivial Ariadne.ctr) | Prims.Tot | [
"total"
] | [] | [
"Ariadne.trivial",
"Ariadne.ctr",
"Ariadne.key",
"Ariadne.backup",
"Prims.list",
"Ariadne.state",
"Ariadne.store",
"Prims.unit",
"FStar.Pervasives.Native.option",
"Ariadne.recover",
"FStar.ST.read",
"Ariadne.log_pre",
"Ariadne.protected",
"Ariadne.create"
] | [] | false | false | false | true | false | let example attack =
| let p = create "hello" in
let Protect c k = p in
store p "world";
attack c;
match read k with
| r :: _ ->
(match recover p r with
| Some _ -> store p "!\n"
| _ -> ())
| _ -> () | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_update_multi_equiv_vale | val lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq byte) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % size_k_w_256 == 0 /\
hash' == update_multi_opaque_vale hash blocks) | val lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq byte) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % size_k_w_256 == 0 /\
hash' == update_multi_opaque_vale hash blocks) | let rec lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq UInt8.t) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % 64 == 0 /\
hash' == update_multi_opaque_vale hash blocks)
(decreases (length quads))
=
lemma_mod_transform quads;
assert (length blocks % 64 == 0);
update_multi_reveal ();
if length quads = 0 then begin
lemma_le_seq_quad32_to_bytes_length quads;
lemma_update_multi_quads_short r_quads hash;
assert (equal blocks empty);
update_multi_zero SHA2_256 hash;
()
end else begin
let num_blocks = (length quads) / 4 in
let bytes_pivot = (num_blocks - 1) * 64 in
// Use associativity of update_multi to rearrange recursion to better match update_multi_quads' recursion
let input1,input2 = Lib.UpdateMulti.split_block block_length blocks (bytes_pivot / 64) in
let h_bytes1 = update_multi SHA2_256 hash () input1 in
let h_bytes2 = update_multi SHA2_256 h_bytes1 () input2 in
update_multi_associative SHA2_256 hash input1 input2;
assert (input1 `Seq.append` input2 == blocks);
Seq.lemma_eq_intro h_bytes2 (update_multi SHA2_256 hash () blocks);
assert (h_bytes2 == update_multi SHA2_256 hash () blocks);
// Unfold update_multi_quads one level, so we can start matching parts up
let prefix, qs = split r_quads (length r_quads - 4) in
let h_prefix = update_multi_quads prefix hash in
let h_final = update_block h_prefix (quads_to_block_be qs) in
lemma_update_multi_quads_unfold r_quads hash;
(* Step 1: Show that h_prefix == h_bytes1 *)
let r_prefix = reverse_bytes_quad32_seq prefix in
lemma_update_multi_equiv_vale hash h_prefix r_prefix prefix
(le_seq_quad32_to_bytes r_prefix)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix));
assert (h_prefix == update_multi SHA2_256 hash () (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix)));
assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) 0 bytes_pivot)
(seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)));
slice_commutes_le_seq_quad32_to_bytes0 quads (bytes_pivot / 16);
assert (bytes_pivot / 16 == length quads - 4);
assert (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq (slice quads 0 (length quads - 4))) == slice quads 0 (length quads - 4));
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_quad32 quads 0 (length quads - 4);
assert (Seq.equal h_prefix h_bytes1); // Conclusion of Step 1
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_quad32 quads (length quads - 4) (length quads);
slice_commutes_le_seq_quad32_to_bytes quads (bytes_pivot/16) ((length blocks)/16);
(* Step 2: Show that update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2 *)
assert (equal input2 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))));
lemma_endian_relation (slice quads (length quads - 4) (length quads)) qs
input2; // ==> quads_to_block qs == words_of_bytes SHA2_256 (block_word_length SHA2_256) input2
lemma_update_block_equiv h_bytes1 input2;
update_multi_one h_bytes1 input2;
()
end | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 835,
"start_col": 0,
"start_line": 769
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ()
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
#reset-options "--z3rlimit 20"
let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in
let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in
word_to_nat32 h.[0] == add_wrap t1 t2 /\
word_to_nat32 h.[1] == a0 /\
word_to_nat32 h.[2] == b0 /\
word_to_nat32 h.[3] == c0 /\
word_to_nat32 h.[4] == add_wrap d0 t1 /\
word_to_nat32 h.[5] == e0 /\
word_to_nat32 h.[6] == f0 /\
word_to_nat32 h.[7] == g0))
=
let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
ch_256_reveal ();
maj_256_reveal ();
lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0);
lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t);
lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0));
lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t));
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig;
shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
#reset-options "--fuel 1 --z3rlimit 50"
let lemma_ws_opaque (block:block_w) (t:counter) : Lemma
(requires 16 <= t && t < size_k_w_256)
(ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16))))
=
let t16 = ws SHA2_256 block (t - 16) in
let t15 = ws SHA2_256 block (t - 15) in
let t7 = ws SHA2_256 block (t - 7) in
let t2 = ws SHA2_256 block (t - 2) in
let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
calc (==) {
ws_opaque block t;
(==) { Pervasives.reveal_opaque (`%ws) ws }
vv ((s1 +. t7 +. s0) +. t16);
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7 +. s0)) (ws_opaque block (t-16)) }
add_wrap (vv ((s1 +. t7) +. s0)) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7)) sigma0 }
add_wrap (add_wrap (vv (s1 +. t7)) sigma0) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod sigma1 (ws_opaque block (t-7)) }
add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16));
}
#reset-options "--fuel 0 --ifuel 0 --z3rlimit 20"
let translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old:quad32) : Lemma
(requires a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old)
(ensures (
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
let update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a b c d e f g h ==
repeat_range_vale_64 block hash_orig /\
a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old))
(ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block))
=
let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec r (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
r (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
r 64;
translate_hash_update a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_seperated_hash_quad32 a' b' c' d' e' f' g' h') (update_block hash_orig block));
()
#push-options "--max_fuel 1"
let lemma_slice_commutes_reverse_bytes_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_quad32_seq s) 0 pivot == reverse_bytes_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_quad32_seq s in
let srs = slice (reverse_bytes_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
=
let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
lemma_slice_commutes_reverse_bytes_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_quad32_seq s) 0 (bound + 4));
if bound = 0 then ()
else (
let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()
)
#pop-options
#push-options "--max_fuel 1"
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block_be qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
#pop-options
let lemma_le_bytes_to_hash_quads_part1 (s:seq quad32) : Lemma
(requires length s == 2)
(ensures le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s))
=
let lhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
assert (lhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)));
le_seq_quad32_to_bytes_reveal ();
Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s);
()
#push-options "--z3rlimit 30"
let lemma_le_bytes_to_hash_quads (s:seq quad32) : Lemma
(requires length s == 2)
(ensures (let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[0] == to_uint32 (s.[0]).lo0 /\
rhs.[1] == to_uint32 (s.[0]).lo1 /\
rhs.[2] == to_uint32 (s.[0]).hi2 /\
rhs.[3] == to_uint32 (s.[0]).hi3 /\
rhs.[4] == to_uint32 (s.[1]).lo0 /\
rhs.[5] == to_uint32 (s.[1]).lo1 /\
rhs.[6] == to_uint32 (s.[1]).hi2 /\
rhs.[7] == to_uint32 (s.[1]).hi3 /\
length rhs == 8))
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
lemma_le_bytes_to_hash_quads_part1 s;
assert (rhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s));
()
#pop-options
let lemma_hash_to_bytes (s:seq quad32) : Lemma
(requires length s == 2)
(ensures make_ordered_hash s.[0] s.[1] == le_bytes_to_hash (le_seq_quad32_to_bytes s))
=
lemma_le_bytes_to_hash_quads s;
assert (equal (make_ordered_hash s.[0] s.[1]) (le_bytes_to_hash (le_seq_quad32_to_bytes s)));
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 40"
let lemma_endian_relation (quads qs:seq quad32) (input2:seq UInt8.t) : Lemma
(requires length qs == 4 /\ length input2 == 64 /\
qs == reverse_bytes_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block_be qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)
=
let fi (i:nat{i < length (quads_to_block_be qs)}) : Lemma
((quads_to_block_be qs).[i] == (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i])
=
let open Vale.Def.Words.Four_s in
let open Vale.Lib.Seqs_s in
let ni = (seq_four_to_seq_LE quads).[i] in
let b = slice input2 (4 * i) (4 * i + 4) in
calc (==) {
b;
== {}
slice input2 (4 * i) (4 * i + 4);
== {}
slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) (4 * i) (4 * i + 4);
== {le_seq_quad32_to_bytes_reveal ()}
slice (seq_nat8_to_seq_uint8 (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4);
equal {}
seq_nat8_to_seq_uint8 (slice (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads)) (4 * i) (4 * i + 4));
== {}
seq_nat8_to_seq_uint8 (slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4));
== {slice_commutes_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)}
seq_nat8_to_seq_uint8 (seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)));
equal {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8)}
seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 (seq_four_to_seq_LE quads).[i]));
};
let open Lib.IntTypes in
calc (==) {
(words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i];
== { }
(Lib.ByteSequence.uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2).[i];
== { Lib.ByteSequence.index_uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2 i }
Lib.ByteSequence.uint_from_bytes_be (Lib.Sequence.sub #uint8 #64 input2 (i * 4) 4);
== { let open Lib.Sequence in
calc (==) {
sub #uint8 #64 input2 (i * 4) 4;
== { }
Seq.slice input2 (4 * i) (4 * i + 4);
}
}
Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b;
== { calc (==) {
Lib.ByteSequence.nat_from_bytes_be #SEC b;
(==) { }
Lib.ByteSequence.nat_from_bytes_be #SEC (seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 ni)));
(==) { lemma_be_to_n_4 (four_to_seq_LE (nat_to_four 8 ni)) }
be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni));
};
v_inj (Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b)
(u32 (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni))))
}
nat32_to_word (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni)));
== {}
nat32_to_word (be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes ni)));
== {reverse_bytes_nat32_reveal ()}
nat32_to_word (reverse_bytes_nat32 ni);
== {}
nat32_to_word (reverse_bytes_nat32 (seq_four_to_seq_LE quads).[i]);
== {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32); reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32); reveal_reverse_bytes_quad32 quads.[(i / 4)]}
nat32_to_word (seq_four_to_seq_BE qs).[i];
== {}
(quads_to_block_be qs).[i];
}
in
FStar.Classical.forall_intro fi;
assert (equal (quads_to_block_be qs) (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
hash: Vale.SHA.PPC64LE.SHA_helpers.hash256 ->
hash': Vale.SHA.PPC64LE.SHA_helpers.hash256 ->
quads: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
r_quads: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
nat8s: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 ->
blocks: FStar.Seq.Base.seq Vale.SHA.PPC64LE.SHA_helpers.byte
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length quads % 4 == 0 /\
r_quads == Vale.Arch.Types.reverse_bytes_quad32_seq quads /\
nat8s == Vale.Def.Types_s.le_seq_quad32_to_bytes quads /\
blocks == Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 nat8s /\
hash' == Vale.SHA.PPC64LE.SHA_helpers.update_multi_quads r_quads hash)
(ensures
FStar.Seq.Base.length blocks % Vale.SHA.PPC64LE.SHA_helpers.size_k_w_256 == 0 /\
hash' == Vale.SHA.PPC64LE.SHA_helpers.update_multi_opaque_vale hash blocks)
(decreases FStar.Seq.Base.length quads) | FStar.Pervasives.Lemma | [
"",
"lemma"
] | [] | [
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Vale.Def.Words_s.nat8",
"FStar.UInt8.t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.unit",
"Spec.Hash.Lemmas.update_multi_zero",
"Spec.Hash.Definitions.SHA2_256",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.empty",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_update_multi_quads_short",
"Vale.Arch.Types.lemma_le_seq_quad32_to_bytes_length",
"Prims.bool",
"Lib.UpdateMulti.uint8",
"Vale.SHA.PPC64LE.SHA_helpers.update_multi_one",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_update_block_equiv",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_endian_relation",
"FStar.Seq.Base.slice",
"Prims.op_Subtraction",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.Arch.Types.slice_commutes_le_seq_quad32_to_bytes",
"Prims.op_Division",
"Vale.Lib.Seqs.slice_seq_map_commute",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Prims.eq2",
"Vale.Arch.Types.reverse_bytes_quad32_seq",
"Vale.Arch.Types.slice_commutes_le_seq_quad32_to_bytes0",
"Vale.Def.Types_s.nat8",
"Spec.Hash.Definitions.word",
"Prims.l_or",
"Prims.nat",
"Spec.Hash.Definitions.state_word_length",
"Prims.b2t",
"Spec.Agile.Hash.update_multi",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_update_multi_equiv_vale",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_update_multi_quads_unfold",
"Vale.SHA.PPC64LE.SHA_helpers.update_block",
"Vale.SHA.PPC64LE.SHA_helpers.quads_to_block_be",
"Vale.SHA.PPC64LE.SHA_helpers.update_multi_quads",
"FStar.Pervasives.Native.tuple2",
"FStar.Seq.Properties.split",
"Spec.Hash.Definitions.words_state",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Seq.Base.append",
"Spec.Hash.Lemmas.update_multi_associative",
"Lib.UpdateMulti.split_block",
"Vale.SHA.PPC64LE.SHA_helpers.block_length",
"FStar.Mul.op_Star",
"Vale.SHA.PPC64LE.SHA_helpers.update_multi_reveal",
"Prims.op_Modulus",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_mod_transform",
"Prims.l_and",
"Prims.squash",
"Vale.SHA.PPC64LE.SHA_helpers.update_multi_opaque_vale",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_update_multi_equiv_vale
(hash hash': hash256)
(quads r_quads: seq quad32)
(nat8s: seq nat8)
(blocks: seq UInt8.t)
: Lemma
(requires
length quads % 4 == 0 /\ r_quads == reverse_bytes_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\ blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures length blocks % 64 == 0 /\ hash' == update_multi_opaque_vale hash blocks)
(decreases (length quads)) =
| lemma_mod_transform quads;
assert (length blocks % 64 == 0);
update_multi_reveal ();
if length quads = 0
then
(lemma_le_seq_quad32_to_bytes_length quads;
lemma_update_multi_quads_short r_quads hash;
assert (equal blocks empty);
update_multi_zero SHA2_256 hash;
())
else
let num_blocks = (length quads) / 4 in
let bytes_pivot = (num_blocks - 1) * 64 in
let input1, input2 = Lib.UpdateMulti.split_block block_length blocks (bytes_pivot / 64) in
let h_bytes1 = update_multi SHA2_256 hash () input1 in
let h_bytes2 = update_multi SHA2_256 h_bytes1 () input2 in
update_multi_associative SHA2_256 hash input1 input2;
assert (input1 `Seq.append` input2 == blocks);
Seq.lemma_eq_intro h_bytes2 (update_multi SHA2_256 hash () blocks);
assert (h_bytes2 == update_multi SHA2_256 hash () blocks);
let prefix, qs = split r_quads (length r_quads - 4) in
let h_prefix = update_multi_quads prefix hash in
let h_final = update_block h_prefix (quads_to_block_be qs) in
lemma_update_multi_quads_unfold r_quads hash;
let r_prefix = reverse_bytes_quad32_seq prefix in
lemma_update_multi_equiv_vale hash
h_prefix
r_prefix
prefix
(le_seq_quad32_to_bytes r_prefix)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix));
assert (h_prefix ==
update_multi SHA2_256 hash () (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix)));
assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) 0 bytes_pivot)
(seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)));
slice_commutes_le_seq_quad32_to_bytes0 quads (bytes_pivot / 16);
assert (bytes_pivot / 16 == length quads - 4);
assert (reverse_bytes_quad32_seq (reverse_bytes_quad32_seq (slice quads 0 (length quads - 4))) ==
slice quads 0 (length quads - 4));
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_quad32 quads 0 (length quads - 4);
assert (Seq.equal h_prefix h_bytes1);
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_quad32 quads (length quads - 4) (length quads);
slice_commutes_le_seq_quad32_to_bytes quads (bytes_pivot / 16) ((length blocks) / 16);
assert (equal input2
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (slice quads
(length quads - 4)
(length quads)))));
lemma_endian_relation (slice quads (length quads - 4) (length quads)) qs input2;
lemma_update_block_equiv h_bytes1 input2;
update_multi_one h_bytes1 input2;
() | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.update_lemma | val update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a b c d e f g h ==
repeat_range_vale_64 block hash_orig /\
a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old))
(ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block)) | val update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a b c d e f g h ==
repeat_range_vale_64 block hash_orig /\
a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old))
(ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block)) | let update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a b c d e f g h ==
repeat_range_vale_64 block hash_orig /\
a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old))
(ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block))
=
let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec r (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
r (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
r 64;
translate_hash_update a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_seperated_hash_quad32 a' b' c' d' e' f' g' h') (update_block hash_orig block));
() | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 584,
"start_col": 0,
"start_line": 548
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ()
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
#reset-options "--z3rlimit 20"
let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in
let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in
word_to_nat32 h.[0] == add_wrap t1 t2 /\
word_to_nat32 h.[1] == a0 /\
word_to_nat32 h.[2] == b0 /\
word_to_nat32 h.[3] == c0 /\
word_to_nat32 h.[4] == add_wrap d0 t1 /\
word_to_nat32 h.[5] == e0 /\
word_to_nat32 h.[6] == f0 /\
word_to_nat32 h.[7] == g0))
=
let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
ch_256_reveal ();
maj_256_reveal ();
lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0);
lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t);
lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0));
lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t));
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig;
shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
#reset-options "--fuel 1 --z3rlimit 50"
let lemma_ws_opaque (block:block_w) (t:counter) : Lemma
(requires 16 <= t && t < size_k_w_256)
(ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16))))
=
let t16 = ws SHA2_256 block (t - 16) in
let t15 = ws SHA2_256 block (t - 15) in
let t7 = ws SHA2_256 block (t - 7) in
let t2 = ws SHA2_256 block (t - 2) in
let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
calc (==) {
ws_opaque block t;
(==) { Pervasives.reveal_opaque (`%ws) ws }
vv ((s1 +. t7 +. s0) +. t16);
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7 +. s0)) (ws_opaque block (t-16)) }
add_wrap (vv ((s1 +. t7) +. s0)) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7)) sigma0 }
add_wrap (add_wrap (vv (s1 +. t7)) sigma0) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod sigma1 (ws_opaque block (t-7)) }
add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16));
}
#reset-options "--fuel 0 --ifuel 0 --z3rlimit 20"
let translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old:quad32) : Lemma
(requires a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old)
(ensures (
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
() | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Vale.Def.Types_s.quad32 ->
b: Vale.Def.Types_s.quad32 ->
c: Vale.Def.Types_s.quad32 ->
d: Vale.Def.Types_s.quad32 ->
e: Vale.Def.Types_s.quad32 ->
f: Vale.Def.Types_s.quad32 ->
g: Vale.Def.Types_s.quad32 ->
h: Vale.Def.Types_s.quad32 ->
a_old: Vale.Def.Types_s.quad32 ->
b_old: Vale.Def.Types_s.quad32 ->
c_old: Vale.Def.Types_s.quad32 ->
d_old: Vale.Def.Types_s.quad32 ->
e_old: Vale.Def.Types_s.quad32 ->
f_old: Vale.Def.Types_s.quad32 ->
g_old: Vale.Def.Types_s.quad32 ->
h_old: Vale.Def.Types_s.quad32 ->
a': Vale.Def.Types_s.quad32 ->
b': Vale.Def.Types_s.quad32 ->
c': Vale.Def.Types_s.quad32 ->
d': Vale.Def.Types_s.quad32 ->
e': Vale.Def.Types_s.quad32 ->
f': Vale.Def.Types_s.quad32 ->
g': Vale.Def.Types_s.quad32 ->
h': Vale.Def.Types_s.quad32 ->
block: Vale.SHA.PPC64LE.SHA_helpers.block_w
-> FStar.Pervasives.Lemma
(requires
(let hash_orig =
Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 a_old
b_old
c_old
d_old
e_old
f_old
g_old
h_old
in
Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 a b c d e f g h ==
Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale_64 block hash_orig /\
a' == Vale.Arch.Types.add_wrap_quad32 a a_old /\
b' == Vale.Arch.Types.add_wrap_quad32 b b_old /\
c' == Vale.Arch.Types.add_wrap_quad32 c c_old /\
d' == Vale.Arch.Types.add_wrap_quad32 d d_old /\
e' == Vale.Arch.Types.add_wrap_quad32 e e_old /\
f' == Vale.Arch.Types.add_wrap_quad32 f f_old /\
g' == Vale.Arch.Types.add_wrap_quad32 g g_old /\
h' == Vale.Arch.Types.add_wrap_quad32 h h_old))
(ensures
(let hash_orig =
Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 a_old
b_old
c_old
d_old
e_old
f_old
g_old
h_old
in
Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32 a' b' c' d' e' f' g' h' ==
Vale.SHA.PPC64LE.SHA_helpers.update_block hash_orig block)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.quad32",
"Vale.SHA.PPC64LE.SHA_helpers.block_w",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Vale.SHA.PPC64LE.SHA_helpers.make_seperated_hash_quad32",
"Vale.SHA.PPC64LE.SHA_helpers.update_block",
"Spec.SHA2.Lemmas.shuffle_is_shuffle_pre",
"Spec.Hash.Definitions.SHA2_256",
"Vale.SHA.PPC64LE.SHA_helpers.translate_hash_update",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.l_or",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.state_word_length",
"Spec.Loops.repeat_range",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Vale.SHA.PPC64LE.SHA_helpers.shuffle_core_opaque",
"Spec.Hash.Definitions.words_state",
"Spec.SHA2.Lemmas.shuffle_core",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Spec.Loops.repeat_range_base",
"Prims.bool",
"Spec.Loops.repeat_range_induction",
"Prims.op_Subtraction",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.block_w",
"Spec.SHA2.counter",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.SHA2.shuffle",
"Vale.SHA.PPC64LE.SHA_helpers.shuffle_opaque",
"Prims.l_and",
"Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale_64",
"Vale.Arch.Types.add_wrap_quad32"
] | [] | false | false | true | false | false | let update_lemma
(a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':
quad32)
(block: block_w)
: Lemma
(requires
(let hash_orig =
make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old
in
make_seperated_hash_quad32 a b c d e f g h == repeat_range_vale_64 block hash_orig /\
a' == add_wrap_quad32 a a_old /\ b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\ d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\ f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\ h' == add_wrap_quad32 h h_old))
(ensures
(let hash_orig =
make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old
in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block)) =
| let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec r (i: nat{i <= 64})
: Lemma
(Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig) =
if i = 0
then
(Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig)
else
(r (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig)
in
r 64;
translate_hash_update a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old
g_old h_old;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_seperated_hash_quad32 a' b' c' d' e' f' g' h') (update_block hash_orig block));
() | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_hash_to_bytes | val lemma_hash_to_bytes (s:seq quad32) : Lemma
(requires length s == 2)
(ensures make_ordered_hash s.[0] s.[1] == le_bytes_to_hash (le_seq_quad32_to_bytes s)) | val lemma_hash_to_bytes (s:seq quad32) : Lemma
(requires length s == 2)
(ensures make_ordered_hash s.[0] s.[1] == le_bytes_to_hash (le_seq_quad32_to_bytes s)) | let lemma_hash_to_bytes (s:seq quad32) : Lemma
(requires length s == 2)
(ensures make_ordered_hash s.[0] s.[1] == le_bytes_to_hash (le_seq_quad32_to_bytes s))
=
lemma_le_bytes_to_hash_quads s;
assert (equal (make_ordered_hash s.[0] s.[1]) (le_bytes_to_hash (le_seq_quad32_to_bytes s)));
() | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 693,
"start_col": 0,
"start_line": 687
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ()
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
#reset-options "--z3rlimit 20"
let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in
let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in
word_to_nat32 h.[0] == add_wrap t1 t2 /\
word_to_nat32 h.[1] == a0 /\
word_to_nat32 h.[2] == b0 /\
word_to_nat32 h.[3] == c0 /\
word_to_nat32 h.[4] == add_wrap d0 t1 /\
word_to_nat32 h.[5] == e0 /\
word_to_nat32 h.[6] == f0 /\
word_to_nat32 h.[7] == g0))
=
let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
ch_256_reveal ();
maj_256_reveal ();
lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0);
lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t);
lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0));
lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t));
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig;
shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
#reset-options "--fuel 1 --z3rlimit 50"
let lemma_ws_opaque (block:block_w) (t:counter) : Lemma
(requires 16 <= t && t < size_k_w_256)
(ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16))))
=
let t16 = ws SHA2_256 block (t - 16) in
let t15 = ws SHA2_256 block (t - 15) in
let t7 = ws SHA2_256 block (t - 7) in
let t2 = ws SHA2_256 block (t - 2) in
let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
calc (==) {
ws_opaque block t;
(==) { Pervasives.reveal_opaque (`%ws) ws }
vv ((s1 +. t7 +. s0) +. t16);
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7 +. s0)) (ws_opaque block (t-16)) }
add_wrap (vv ((s1 +. t7) +. s0)) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7)) sigma0 }
add_wrap (add_wrap (vv (s1 +. t7)) sigma0) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod sigma1 (ws_opaque block (t-7)) }
add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16));
}
#reset-options "--fuel 0 --ifuel 0 --z3rlimit 20"
let translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old:quad32) : Lemma
(requires a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old)
(ensures (
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
let update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a b c d e f g h ==
repeat_range_vale_64 block hash_orig /\
a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old))
(ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block))
=
let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec r (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
r (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
r 64;
translate_hash_update a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_seperated_hash_quad32 a' b' c' d' e' f' g' h') (update_block hash_orig block));
()
#push-options "--max_fuel 1"
let lemma_slice_commutes_reverse_bytes_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_quad32_seq s) 0 pivot == reverse_bytes_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_quad32_seq s in
let srs = slice (reverse_bytes_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
=
let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
lemma_slice_commutes_reverse_bytes_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_quad32_seq s) 0 (bound + 4));
if bound = 0 then ()
else (
let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()
)
#pop-options
#push-options "--max_fuel 1"
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block_be qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
#pop-options
let lemma_le_bytes_to_hash_quads_part1 (s:seq quad32) : Lemma
(requires length s == 2)
(ensures le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s))
=
let lhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
assert (lhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)));
le_seq_quad32_to_bytes_reveal ();
Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s);
()
#push-options "--z3rlimit 30"
let lemma_le_bytes_to_hash_quads (s:seq quad32) : Lemma
(requires length s == 2)
(ensures (let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[0] == to_uint32 (s.[0]).lo0 /\
rhs.[1] == to_uint32 (s.[0]).lo1 /\
rhs.[2] == to_uint32 (s.[0]).hi2 /\
rhs.[3] == to_uint32 (s.[0]).hi3 /\
rhs.[4] == to_uint32 (s.[1]).lo0 /\
rhs.[5] == to_uint32 (s.[1]).lo1 /\
rhs.[6] == to_uint32 (s.[1]).hi2 /\
rhs.[7] == to_uint32 (s.[1]).hi3 /\
length rhs == 8))
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
lemma_le_bytes_to_hash_quads_part1 s;
assert (rhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s));
()
#pop-options | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length s == 2)
(ensures
Vale.SHA.PPC64LE.SHA_helpers.make_ordered_hash s.[ 0 ] s.[ 1 ] ==
Vale.SHA.PPC64LE.SHA_helpers.le_bytes_to_hash (Vale.Def.Types_s.le_seq_quad32_to_bytes s)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Vale.SHA.PPC64LE.SHA_helpers.make_ordered_hash",
"Spec.SHA2.op_String_Access",
"Vale.SHA.PPC64LE.SHA_helpers.le_bytes_to_hash",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_le_bytes_to_hash_quads",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.squash",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_hash_to_bytes (s: seq quad32)
: Lemma (requires length s == 2)
(ensures make_ordered_hash s.[ 0 ] s.[ 1 ] == le_bytes_to_hash (le_seq_quad32_to_bytes s)) =
| lemma_le_bytes_to_hash_quads s;
assert (equal (make_ordered_hash s.[ 0 ] s.[ 1 ]) (le_bytes_to_hash (le_seq_quad32_to_bytes s)));
() | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_update_multi_quads | val lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
h == update_multi_quads input_BE hash_orig)) | val lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
h == update_multi_quads input_BE hash_orig)) | let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
=
let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
lemma_slice_commutes_reverse_bytes_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_quad32_seq s) 0 (bound + 4));
if bound = 0 then ()
else (
let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()
) | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 634,
"start_col": 0,
"start_line": 604
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
()
let sigma_0_0_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma0_in = ws_opaque block (t-15) in
sigma256_0_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma0 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-15))
(ensures (sigma256_0_0 src.hi3 == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_0_1_partial_def (t:counter) (block:block_w) : nat32 =
if 16 <= t && t < size_k_w_256 then
(let sigma1_in = ws_opaque block (t-2) in
sigma256_0_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma1 (src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
src.hi3 == ws_opaque block (t-2))
(ensures (sigma256_0_1 src.hi3 == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_0_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma0_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[0]) in
sigma256_1_0 sigma0_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma2 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[0]))
(ensures (sigma256_1_0 src.hi3 == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let sigma_1_1_partial_def (t:counter) (block:block_w) (hash_orig:hash256) : nat32 =
if t < size_k_w_256 then
(let sigma1_in = word_to_nat32 ((repeat_range_vale t block hash_orig).[4]) in
sigma256_1_1 sigma1_in)
else
0
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
let lemma_sha256_sigma3 (src:quad32) (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256) /\
src.hi3 == word_to_nat32 ((repeat_range_vale t block hash_orig).[4]))
(ensures (sigma256_1_1 src.hi3 == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let make_seperated_hash_def (a b c d e f g h:nat32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a /\
hash.[1] == to_uint32 b /\
hash.[2] == to_uint32 c /\
hash.[3] == to_uint32 d /\
hash.[4] == to_uint32 e /\
hash.[5] == to_uint32 f /\
hash.[6] == to_uint32 g /\
hash.[7] == to_uint32 h
})
=
let a = to_uint32 a in
let b = to_uint32 b in
let c = to_uint32 c in
let d = to_uint32 d in
let e = to_uint32 e in
let f = to_uint32 f in
let g = to_uint32 g in
let h = to_uint32 h in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash = opaque_make make_seperated_hash_def
irreducible let make_seperated_hash_reveal = opaque_revealer (`%make_seperated_hash) make_seperated_hash make_seperated_hash_def
let make_seperated_hash_quad32_def (a b c d e f g h:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 a.hi3 /\
hash.[1] == to_uint32 b.hi3 /\
hash.[2] == to_uint32 c.hi3 /\
hash.[3] == to_uint32 d.hi3 /\
hash.[4] == to_uint32 e.hi3 /\
hash.[5] == to_uint32 f.hi3 /\
hash.[6] == to_uint32 g.hi3 /\
hash.[7] == to_uint32 h.hi3
})
=
let a = to_uint32 a.hi3 in
let b = to_uint32 b.hi3 in
let c = to_uint32 c.hi3 in
let d = to_uint32 d.hi3 in
let e = to_uint32 e.hi3 in
let f = to_uint32 f.hi3 in
let g = to_uint32 g.hi3 in
let h = to_uint32 h.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_seperated_hash_quad32 = opaque_make make_seperated_hash_quad32_def
irreducible let make_seperated_hash_quad32_reveal = opaque_revealer (`%make_seperated_hash_quad32) make_seperated_hash_quad32 make_seperated_hash_quad32_def
let lemma_make_seperated_hash (hash:hash256) (a b c d e f g h:quad32) : Lemma
(requires length hash == 8 /\
a.hi3 == word_to_nat32 hash.[0] /\
b.hi3 == word_to_nat32 hash.[1] /\
c.hi3 == word_to_nat32 hash.[2] /\
d.hi3 == word_to_nat32 hash.[3] /\
e.hi3 == word_to_nat32 hash.[4] /\
f.hi3 == word_to_nat32 hash.[5] /\
g.hi3 == word_to_nat32 hash.[6] /\
h.hi3 == word_to_nat32 hash.[7])
(ensures hash == make_seperated_hash_quad32 a b c d e f g h)
=
assert (equal hash (make_seperated_hash_quad32 a b c d e f g h))
let lemma_vsel32 (a b c:nat32) : Lemma
(ensures (isel32 a b c = (iand32 c a) *^ (iand32 (inot32 c) b)))
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 a b c) ((iand32 c a) *^ (iand32 (inot32 c) b))
let ch_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ (iand32 (inot32 x) z)})
=
reveal_iand_all 32;
reveal_inot_all 32;
reveal_ixor_all 32;
ch256 x y z
[@"opaque_to_smt"] let ch_256 = opaque_make ch_256_def
irreducible let ch_256_reveal = opaque_revealer (`%ch_256) ch_256 ch_256_def
let lemma_eq_maj_xvsel32 (a b c:nat32) : Lemma
(ensures (isel32 c b (a *^ b) = (iand32 a b) *^ ((iand32 a c) *^ (iand32 b c))))
=
reveal_iand_all 32;
reveal_ixor_all 32;
lemma_equal_nth 32 (isel32 c b (a *^ b)) ((iand32 a b) *^ ((iand32 a c) *^ (iand32 b c)))
let maj_256_def (x y z:nat32) :
(a:nat32 {a == (iand32 x y) *^ ((iand32 x z) *^ (iand32 y z))})
=
reveal_iand_all 32;
reveal_ixor_all 32;
maj256 x y z
[@"opaque_to_smt"] let maj_256 = opaque_make maj_256_def
irreducible let maj_256_reveal = opaque_revealer (`%maj_256) maj_256 maj_256_def
let lemma_sigma_0_0_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_0 (ws_opaque block (t-15)) == sigma_0_0_partial t block))
=
sigma_0_0_partial_reveal ()
let lemma_sigma_0_1_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256))
(ensures (sigma256_0_1 (ws_opaque block (t-2)) == sigma_0_1_partial t block))
=
sigma_0_1_partial_reveal ()
let lemma_sigma_1_0_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_0 (word_to_nat32 ((repeat_range_vale t block hash_orig).[0])) == sigma_1_0_partial t block hash_orig))
=
sigma_1_0_partial_reveal ()
let lemma_sigma_1_1_partial (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w(SHA2_256))
(ensures (sigma256_1_1 (word_to_nat32 ((repeat_range_vale t block hash_orig).[4])) == sigma_1_1_partial t block hash_orig))
=
sigma_1_1_partial_reveal ()
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block_be qs
=
reveal_opaque (`%seq_four_to_seq_BE) (seq_four_to_seq_BE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
#reset-options "--z3rlimit 20"
let lemma_shuffle_core_properties (t:counter) (block:block_w) (hash_orig:hash256) : Lemma
(requires t < size_k_w_256)
(ensures (let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let h = Spec.Loops.repeat_range 0 (t + 1) (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
let t1 = add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t) in
let t2 = add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0) in
word_to_nat32 h.[0] == add_wrap t1 t2 /\
word_to_nat32 h.[1] == a0 /\
word_to_nat32 h.[2] == b0 /\
word_to_nat32 h.[3] == c0 /\
word_to_nat32 h.[4] == add_wrap d0 t1 /\
word_to_nat32 h.[5] == e0 /\
word_to_nat32 h.[6] == f0 /\
word_to_nat32 h.[7] == g0))
=
let hash = Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig in
let a0 = word_to_nat32 hash.[0] in
let b0 = word_to_nat32 hash.[1] in
let c0 = word_to_nat32 hash.[2] in
let d0 = word_to_nat32 hash.[3] in
let e0 = word_to_nat32 hash.[4] in
let f0 = word_to_nat32 hash.[5] in
let g0 = word_to_nat32 hash.[6] in
let h0 = word_to_nat32 hash.[7] in
ch_256_reveal ();
maj_256_reveal ();
lemma_add_wrap_is_add_mod h0 (sigma256_1_1 e0);
lemma_add_wrap_is_add_mod (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t]);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t);
lemma_add_wrap_is_add_mod (sigma256_1_0 a0) (maj_256 a0 b0 c0);
lemma_add_wrap_is_add_mod (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t)) (add_wrap (sigma256_1_0 a0) (maj_256 a0 b0 c0));
lemma_add_wrap_is_add_mod d0 (add_wrap (add_wrap (add_wrap (add_wrap h0 (sigma256_1_1 e0)) (ch_256 e0 f0 g0)) (word_to_nat32 k.[t])) (ws_opaque block t));
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_orig;
shuffle_core_properties block (Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_orig) t
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
#reset-options "--fuel 1 --z3rlimit 50"
let lemma_ws_opaque (block:block_w) (t:counter) : Lemma
(requires 16 <= t && t < size_k_w_256)
(ensures (let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
ws_opaque block t == add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16))))
=
let t16 = ws SHA2_256 block (t - 16) in
let t15 = ws SHA2_256 block (t - 15) in
let t7 = ws SHA2_256 block (t - 7) in
let t2 = ws SHA2_256 block (t - 2) in
let sigma0 = sigma256_0_0 (ws_opaque block (t - 15)) in
let sigma1 = sigma256_0_1 (ws_opaque block (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
calc (==) {
ws_opaque block t;
(==) { Pervasives.reveal_opaque (`%ws) ws }
vv ((s1 +. t7 +. s0) +. t16);
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7 +. s0)) (ws_opaque block (t-16)) }
add_wrap (vv ((s1 +. t7) +. s0)) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod (vv (s1 +. t7)) sigma0 }
add_wrap (add_wrap (vv (s1 +. t7)) sigma0) (ws_opaque block (t-16));
(==) { lemma_add_wrap_is_add_mod sigma1 (ws_opaque block (t-7)) }
add_wrap (add_wrap (add_wrap sigma1 (ws_opaque block (t - 7))) sigma0) (ws_opaque block (t - 16));
}
#reset-options "--fuel 0 --ifuel 0 --z3rlimit 20"
let translate_hash_update (a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old:quad32) : Lemma
(requires a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old)
(ensures (
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_seperated_hash_quad32 a b c d e f g h in
let a = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let h' = make_seperated_hash_quad32 a' b' c' d' e' f' g' h' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
let update_lemma (a b c d e f g h a_old b_old c_old d_old e_old f_old g_old h_old a' b' c' d' e' f' g' h':quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a b c d e f g h ==
repeat_range_vale_64 block hash_orig /\
a' == add_wrap_quad32 a a_old /\
b' == add_wrap_quad32 b b_old /\
c' == add_wrap_quad32 c c_old /\
d' == add_wrap_quad32 d d_old /\
e' == add_wrap_quad32 e e_old /\
f' == add_wrap_quad32 f f_old /\
g' == add_wrap_quad32 g g_old /\
h' == add_wrap_quad32 h h_old))
(ensures (let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
make_seperated_hash_quad32 a' b' c' d' e' f' g' h' == update_block hash_orig block))
=
let hash_orig = make_seperated_hash_quad32 a_old b_old c_old d_old e_old f_old g_old h_old in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec r (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
r (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
r 64;
translate_hash_update a b c d e f g h a' b' c' d' e' f' g' h' a_old b_old c_old d_old e_old f_old g_old h_old;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_seperated_hash_quad32 a' b' c' d' e' f' g' h') (update_block hash_orig block));
()
#push-options "--max_fuel 1"
let lemma_slice_commutes_reverse_bytes_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_quad32_seq s) 0 pivot == reverse_bytes_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_quad32_seq s in
let srs = slice (reverse_bytes_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_quad32_seq empty));
()
) else (
assert (equal srs rss)
) | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
hash_orig: Vale.SHA.PPC64LE.SHA_helpers.hash256 ->
bound: Prims.nat
-> FStar.Pervasives.Lemma (requires bound + 4 <= FStar.Seq.Base.length s)
(ensures
(let prefix_LE = FStar.Seq.Base.slice s 0 bound in
let prefix_BE = Vale.Arch.Types.reverse_bytes_quad32_seq prefix_LE in
let h_prefix = Vale.SHA.PPC64LE.SHA_helpers.update_multi_quads prefix_BE hash_orig in
let block_quads_LE = FStar.Seq.Base.slice s bound (bound + 4) in
let block_quads_BE = Vale.Arch.Types.reverse_bytes_quad32_seq block_quads_LE in
let input_LE = FStar.Seq.Base.slice s 0 (bound + 4) in
let input_BE = Vale.Arch.Types.reverse_bytes_quad32_seq input_LE in
let h =
Vale.SHA.PPC64LE.SHA_helpers.update_block h_prefix
(Vale.SHA.PPC64LE.SHA_helpers.quads_to_block_be block_quads_BE)
in
h == Vale.SHA.PPC64LE.SHA_helpers.update_multi_quads input_BE hash_orig)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Pervasives.Native.tuple2",
"FStar.Seq.Properties.split",
"Prims.op_Subtraction",
"FStar.Seq.Base.length",
"Prims.eq2",
"FStar.Seq.Base.slice",
"Vale.Arch.Types.reverse_bytes_quad32_seq",
"Prims.op_Addition",
"Vale.SHA.PPC64LE.SHA_helpers.lemma_slice_commutes_reverse_bytes_quad32_seq",
"Vale.SHA.PPC64LE.SHA_helpers.update_block",
"Vale.SHA.PPC64LE.SHA_helpers.quads_to_block_be",
"Vale.SHA.PPC64LE.SHA_helpers.update_multi_quads",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let lemma_update_multi_quads (s: seq quad32) (hash_orig: hash256) (bound: nat)
: Lemma (requires bound + 4 <= length s)
(ensures
(let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound + 4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
h == update_multi_quads input_BE hash_orig)) =
| let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound + 4) in
let input_BE = reverse_bytes_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block_be block_quads_BE) in
lemma_slice_commutes_reverse_bytes_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_quad32_seq s) 0 (bound + 4));
if bound = 0
then ()
else
(let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()) | false |
Vale.X64.InsLemmas.fsti | Vale.X64.InsLemmas.has_taint128 | val has_taint128 (o: operand128) (t: taint) : bool | val has_taint128 (o: operand128) (t: taint) : bool | let has_taint128 (o:operand128) (t:taint) : bool =
match o with
| OMem (_, t') | OStack (_, t') -> t = t'
| _ -> true | {
"file_name": "vale/code/arch/x64/Vale.X64.InsLemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 16,
"start_col": 0,
"start_line": 13
} | module Vale.X64.InsLemmas
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Decls
open Vale.X64.Memory
module BC = Vale.X64.Bytes_Code_s | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsLemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 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 | o: Vale.X64.Machine_s.operand128 -> t: Vale.Arch.HeapTypes_s.taint -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.operand128",
"Vale.Arch.HeapTypes_s.taint",
"Vale.X64.Machine_s.maddr",
"Prims.op_Equality",
"Vale.X64.Machine_s.operand",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Machine_s.reg_xmm",
"Prims.bool"
] | [] | false | false | false | true | false | let has_taint128 (o: operand128) (t: taint) : bool =
| match o with
| OMem (_, t') | OStack (_, t') -> t = t'
| _ -> true | false |
Vale.X64.InsLemmas.fsti | Vale.X64.InsLemmas.make_instr_outs | val make_instr_outs
(outs: list instr_out)
(args: list instr_operand)
(k: arrow (instr_operands_t outs args) S.ins)
: make_instr_t outs args | val make_instr_outs
(outs: list instr_out)
(args: list instr_operand)
(k: arrow (instr_operands_t outs args) S.ins)
: make_instr_t outs args | let rec make_instr_outs
(outs:list instr_out) (args:list instr_operand) (k:arrow (instr_operands_t outs args) S.ins)
: make_instr_t outs args =
match outs with
| [] -> make_instr_args args k
| (b, IOpEx i)::outs -> fun (o:instr_operand_t i) ->
let k = coerce #(arrow (instr_operand_t i & instr_operands_t outs args) S.ins) k in // REVIEW: workaround for F* -> OCaml bug
let k (oprs:instr_operands_t outs args) = k (o, oprs) in
make_instr_outs outs args k
| (_, IOpIm i)::outs -> coerce (make_instr_outs outs args (coerce #(arrow (instr_operands_t outs args) S.ins) k)) | {
"file_name": "vale/code/arch/x64/Vale.X64.InsLemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 115,
"end_line": 64,
"start_col": 0,
"start_line": 55
} | module Vale.X64.InsLemmas
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Decls
open Vale.X64.Memory
module BC = Vale.X64.Bytes_Code_s
module S = Vale.X64.Machine_Semantics_s
let has_taint128 (o:operand128) (t:taint) : bool =
match o with
| OMem (_, t') | OStack (_, t') -> t = t'
| _ -> true
val lemma_valid_src_operand64_and_taint (o:operand64) (s:vale_state) : Lemma
(requires valid_operand o s)
(ensures S.valid_src_operand64_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand64_and_taint o (state_to_S s))]
val lemma_valid_src_operand128_and_taint (o:operand128) (s:vale_state) : Lemma
(requires valid_operand128 o s)
(ensures S.valid_src_operand128_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand128_and_taint o (state_to_S s))]
[@instr_attr]
let rec make_instr_t_args (args:list instr_operand) : Type0 =
match normal args with
| [] -> S.ins
| (IOpEx i)::args -> arrow (instr_operand_t i) (make_instr_t_args args)
| (IOpIm _)::args -> make_instr_t_args args
[@instr_attr]
let rec make_instr_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match normal outs with
| [] -> make_instr_t_args args
| (_, IOpEx i)::outs -> arrow (instr_operand_t i) (make_instr_t outs args)
| (_, IOpIm _)::outs -> make_instr_t outs args
[@instr_attr]
let rec make_instr_args
(args:list instr_operand) (k:arrow (instr_operands_t_args args) S.ins)
: make_instr_t_args args =
match args with
| [] -> k ()
| (IOpEx i)::args -> fun (o:instr_operand_t i) ->
let k = coerce #(arrow (instr_operand_t i & instr_operands_t_args args) S.ins) k in // REVIEW: workaround for F* -> OCaml bug
let k (oprs:instr_operands_t_args args) : S.ins = k (o, oprs) in
make_instr_args args k
| (IOpIm i)::args -> coerce (make_instr_args args (coerce #(arrow (instr_operands_t_args args) S.ins) k)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsLemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 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 |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
k:
Vale.X64.Instruction_s.arrow (Vale.X64.Instruction_s.instr_operands_t outs args)
Vale.X64.Machine_Semantics_s.ins
-> Vale.X64.InsLemmas.make_instr_t outs args | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.arrow",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.InsLemmas.make_instr_args",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.InsLemmas.make_instr_outs",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.StateLemmas.coerce",
"Vale.X64.InsLemmas.make_instr_t",
"Vale.X64.Instruction_s.instr_operand_implicit"
] | [
"recursion"
] | false | false | false | false | false | let rec make_instr_outs
(outs: list instr_out)
(args: list instr_operand)
(k: arrow (instr_operands_t outs args) S.ins)
: make_instr_t outs args =
| match outs with
| [] -> make_instr_args args k
| (b, IOpEx i) :: outs ->
fun (o: instr_operand_t i) ->
let k = coerce #(arrow (instr_operand_t i & instr_operands_t outs args) S.ins) k in
let k (oprs: instr_operands_t outs args) = k (o, oprs) in
make_instr_outs outs args k
| (_, IOpIm i) :: outs ->
coerce (make_instr_outs outs args (coerce #(arrow (instr_operands_t outs args) S.ins) k)) | false |
Vale.X64.InsLemmas.fsti | Vale.X64.InsLemmas.make_instr_t_args | val make_instr_t_args (args: list instr_operand) : Type0 | val make_instr_t_args (args: list instr_operand) : Type0 | let rec make_instr_t_args (args:list instr_operand) : Type0 =
match normal args with
| [] -> S.ins
| (IOpEx i)::args -> arrow (instr_operand_t i) (make_instr_t_args args)
| (IOpIm _)::args -> make_instr_t_args args | {
"file_name": "vale/code/arch/x64/Vale.X64.InsLemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 33,
"start_col": 0,
"start_line": 29
} | module Vale.X64.InsLemmas
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Decls
open Vale.X64.Memory
module BC = Vale.X64.Bytes_Code_s
module S = Vale.X64.Machine_Semantics_s
let has_taint128 (o:operand128) (t:taint) : bool =
match o with
| OMem (_, t') | OStack (_, t') -> t = t'
| _ -> true
val lemma_valid_src_operand64_and_taint (o:operand64) (s:vale_state) : Lemma
(requires valid_operand o s)
(ensures S.valid_src_operand64_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand64_and_taint o (state_to_S s))]
val lemma_valid_src_operand128_and_taint (o:operand128) (s:vale_state) : Lemma
(requires valid_operand128 o s)
(ensures S.valid_src_operand128_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand128_and_taint o (state_to_S s))] | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsLemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 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 | args: Prims.list Vale.X64.Instruction_s.instr_operand -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.normal",
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.arrow",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.InsLemmas.make_instr_t_args",
"Vale.X64.Instruction_s.instr_operand_implicit"
] | [
"recursion"
] | false | false | false | true | true | let rec make_instr_t_args (args: list instr_operand) : Type0 =
| match normal args with
| [] -> S.ins
| IOpEx i :: args -> arrow (instr_operand_t i) (make_instr_t_args args)
| IOpIm _ :: args -> make_instr_t_args args | false |
Vale.X64.InsLemmas.fsti | Vale.X64.InsLemmas.make_instr_args | val make_instr_args (args: list instr_operand) (k: arrow (instr_operands_t_args args) S.ins)
: make_instr_t_args args | val make_instr_args (args: list instr_operand) (k: arrow (instr_operands_t_args args) S.ins)
: make_instr_t_args args | let rec make_instr_args
(args:list instr_operand) (k:arrow (instr_operands_t_args args) S.ins)
: make_instr_t_args args =
match args with
| [] -> k ()
| (IOpEx i)::args -> fun (o:instr_operand_t i) ->
let k = coerce #(arrow (instr_operand_t i & instr_operands_t_args args) S.ins) k in // REVIEW: workaround for F* -> OCaml bug
let k (oprs:instr_operands_t_args args) : S.ins = k (o, oprs) in
make_instr_args args k
| (IOpIm i)::args -> coerce (make_instr_args args (coerce #(arrow (instr_operands_t_args args) S.ins) k)) | {
"file_name": "vale/code/arch/x64/Vale.X64.InsLemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 107,
"end_line": 52,
"start_col": 0,
"start_line": 43
} | module Vale.X64.InsLemmas
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Decls
open Vale.X64.Memory
module BC = Vale.X64.Bytes_Code_s
module S = Vale.X64.Machine_Semantics_s
let has_taint128 (o:operand128) (t:taint) : bool =
match o with
| OMem (_, t') | OStack (_, t') -> t = t'
| _ -> true
val lemma_valid_src_operand64_and_taint (o:operand64) (s:vale_state) : Lemma
(requires valid_operand o s)
(ensures S.valid_src_operand64_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand64_and_taint o (state_to_S s))]
val lemma_valid_src_operand128_and_taint (o:operand128) (s:vale_state) : Lemma
(requires valid_operand128 o s)
(ensures S.valid_src_operand128_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand128_and_taint o (state_to_S s))]
[@instr_attr]
let rec make_instr_t_args (args:list instr_operand) : Type0 =
match normal args with
| [] -> S.ins
| (IOpEx i)::args -> arrow (instr_operand_t i) (make_instr_t_args args)
| (IOpIm _)::args -> make_instr_t_args args
[@instr_attr]
let rec make_instr_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match normal outs with
| [] -> make_instr_t_args args
| (_, IOpEx i)::outs -> arrow (instr_operand_t i) (make_instr_t outs args)
| (_, IOpIm _)::outs -> make_instr_t outs args | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsLemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 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 |
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
k:
Vale.X64.Instruction_s.arrow (Vale.X64.Instruction_s.instr_operands_t_args args)
Vale.X64.Machine_Semantics_s.ins
-> Vale.X64.InsLemmas.make_instr_t_args args | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.arrow",
"Vale.X64.Instruction_s.instr_operands_t_args",
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.InsLemmas.make_instr_args",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.StateLemmas.coerce",
"Vale.X64.InsLemmas.make_instr_t_args",
"Vale.X64.Instruction_s.instr_operand_implicit"
] | [
"recursion"
] | false | false | false | false | false | let rec make_instr_args (args: list instr_operand) (k: arrow (instr_operands_t_args args) S.ins)
: make_instr_t_args args =
| match args with
| [] -> k ()
| IOpEx i :: args ->
fun (o: instr_operand_t i) ->
let k = coerce #(arrow (instr_operand_t i & instr_operands_t_args args) S.ins) k in
let k (oprs: instr_operands_t_args args) : S.ins = k (o, oprs) in
make_instr_args args k
| IOpIm i :: args ->
coerce (make_instr_args args (coerce #(arrow (instr_operands_t_args args) S.ins) k)) | false |
Vale.X64.InsLemmas.fsti | Vale.X64.InsLemmas.make_instr_t | val make_instr_t (outs: list instr_out) (args: list instr_operand) : Type0 | val make_instr_t (outs: list instr_out) (args: list instr_operand) : Type0 | let rec make_instr_t (outs:list instr_out) (args:list instr_operand) : Type0 =
match normal outs with
| [] -> make_instr_t_args args
| (_, IOpEx i)::outs -> arrow (instr_operand_t i) (make_instr_t outs args)
| (_, IOpIm _)::outs -> make_instr_t outs args | {
"file_name": "vale/code/arch/x64/Vale.X64.InsLemmas.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 40,
"start_col": 0,
"start_line": 36
} | module Vale.X64.InsLemmas
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.State
open Vale.X64.StateLemmas
open Vale.X64.Decls
open Vale.X64.Memory
module BC = Vale.X64.Bytes_Code_s
module S = Vale.X64.Machine_Semantics_s
let has_taint128 (o:operand128) (t:taint) : bool =
match o with
| OMem (_, t') | OStack (_, t') -> t = t'
| _ -> true
val lemma_valid_src_operand64_and_taint (o:operand64) (s:vale_state) : Lemma
(requires valid_operand o s)
(ensures S.valid_src_operand64_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand64_and_taint o (state_to_S s))]
val lemma_valid_src_operand128_and_taint (o:operand128) (s:vale_state) : Lemma
(requires valid_operand128 o s)
(ensures S.valid_src_operand128_and_taint o (state_to_S s))
[SMTPat (S.valid_src_operand128_and_taint o (state_to_S s))]
[@instr_attr]
let rec make_instr_t_args (args:list instr_operand) : Type0 =
match normal args with
| [] -> S.ins
| (IOpEx i)::args -> arrow (instr_operand_t i) (make_instr_t_args args)
| (IOpIm _)::args -> make_instr_t_args args | {
"checked_file": "/",
"dependencies": [
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.State.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsLemmas.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 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 |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.normal",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.InsLemmas.make_instr_t_args",
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.arrow",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.InsLemmas.make_instr_t",
"Vale.X64.Instruction_s.instr_operand_implicit"
] | [
"recursion"
] | false | false | false | true | true | let rec make_instr_t (outs: list instr_out) (args: list instr_operand) : Type0 =
| match normal outs with
| [] -> make_instr_t_args args
| (_, IOpEx i) :: outs -> arrow (instr_operand_t i) (make_instr_t outs args)
| (_, IOpIm _) :: outs -> make_instr_t outs args | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.zero_element | val zero_element: a:Spec.alg -> m:m_spec -> element_t a m | val zero_element: a:Spec.alg -> m:m_spec -> element_t a m | let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 22,
"start_col": 0,
"start_line": 17
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1" | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec
-> Hacl.Impl.Blake2.Core.element_t a m | Prims.Tot | [
"total"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntVector.vec_zero",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"FStar.Pervasives.Native.tuple2",
"Spec.Blake2.Definitions.zero",
"Hacl.Impl.Blake2.Core.element_t"
] | [] | false | false | false | false | false | let zero_element (a: Spec.alg) (m: m_spec) : element_t a m =
| match a, m with
| Spec.Blake2S, M128 -> (vec_zero U32 4)
| Spec.Blake2S, M256 -> (vec_zero U32 4)
| Spec.Blake2B, M256 -> (vec_zero U64 4)
| _ -> Spec.zero a | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_lemma_Gcm_blocks_decrypt_stdcall | val va_lemma_Gcm_blocks_decrypt_stdcall : va_b0:va_code -> va_s0:va_state -> win:bool ->
alg:algorithm -> auth_b:buffer128 -> auth_bytes:nat64 -> auth_num:nat64 -> keys_b:buffer128 ->
iv_b:buffer128 -> iv:supported_iv_LE -> hkeys_b:buffer128 -> abytes_b:buffer128 ->
in128x6_b:buffer128 -> out128x6_b:buffer128 -> len128x6_num:nat64 -> in128_b:buffer128 ->
out128_b:buffer128 -> len128_num:nat64 -> inout_b:buffer128 -> cipher_num:nat64 ->
scratch_b:buffer128 -> tag_b:buffer128 -> key:(seq nat32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok
va_s0 /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx
va_s0 else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0
18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in
let (auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\
va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\
Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 ==
len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem
va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem
va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128
tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b])
/\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b;
in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128
scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b;
out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b;
abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b;
inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b;
in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b;
hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16
`op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 <
pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64
/\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 <
pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8)
<= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) +
va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128
`op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division`
8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem
va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0)
hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0)
in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem
va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let
plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let
plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let
expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp
va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi
va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64
rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64
rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm
8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM
== va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12
va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM
(va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout
va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3
va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM
(va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM
(va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15
va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM
(va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRsp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))))))))))))) | val va_lemma_Gcm_blocks_decrypt_stdcall : va_b0:va_code -> va_s0:va_state -> win:bool ->
alg:algorithm -> auth_b:buffer128 -> auth_bytes:nat64 -> auth_num:nat64 -> keys_b:buffer128 ->
iv_b:buffer128 -> iv:supported_iv_LE -> hkeys_b:buffer128 -> abytes_b:buffer128 ->
in128x6_b:buffer128 -> out128x6_b:buffer128 -> len128x6_num:nat64 -> in128_b:buffer128 ->
out128_b:buffer128 -> len128_num:nat64 -> inout_b:buffer128 -> cipher_num:nat64 ->
scratch_b:buffer128 -> tag_b:buffer128 -> key:(seq nat32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok
va_s0 /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx
va_s0 else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0
18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in
let (auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\
va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\
Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==>
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
(win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\
auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 ==
len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem
va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0)
in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout
va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem
va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128
tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b])
/\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b;
in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128
scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b;
hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b;
out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b;
abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b;
inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b;
in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b;
hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b
([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16
`op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 <
pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64
/\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 <
pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8)
<= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) +
va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128
`op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division`
8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem
va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0)
hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0
else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) =
(if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let
(auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else
va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then
va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range
0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8
+ 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in
let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win
then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0
18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 +
56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if
win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)
else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0)
(va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0)
in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem
va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let
plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let
plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let
expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp
va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi
va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64
rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64
rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm
8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM
== va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==>
va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13
va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM
== va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12
va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13
va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM
(va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout
va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3
va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM
(va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM
(va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15
va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM
(va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRsp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))))))))))))) | let va_lemma_Gcm_blocks_decrypt_stdcall va_b0 va_s0 win alg auth_b auth_bytes auth_num keys_b iv_b
iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b
cipher_num scratch_b tag_b key =
let (va_mods:va_mods_t) = [va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi;
va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax;
va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks_decrypt_stdcall va_mods win alg auth_b auth_bytes auth_num keys_b
iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b
cipher_num scratch_b tag_b key in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks_decrypt_stdcall win alg)
va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 764 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _
-> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let
(auth_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx
va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64
rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 32 + 8 + 0) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR8 va_s0) in let
(xip:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR9 va_s0)
in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let
(in128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let
(out128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in
let (len128x6:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in
let (in128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in
let (out128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in
let (inout_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in
let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in
let (tag_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in
label va_range1
"***** POSTCONDITION NOT MET AT line 931 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer
#Vale.X64.Memory.vuint128 iv_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer
#Vale.X64.Memory.vuint128 scratch_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer
#Vale.X64.Memory.vuint128 out128x6_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer
#Vale.X64.Memory.vuint128 out128_b) (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
inout_b))))) (va_get_mem va_s0) (va_get_mem va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 934 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(cipher_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 935 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(auth_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 937 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 939 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 940 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 auth_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 941 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem va_s0) inout_b) in label
va_range1
"***** POSTCONDITION NOT MET AT line 942 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 943 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in label
va_range1
"***** POSTCONDITION NOT MET AT line 944 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 945 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 955 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 958 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 961 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 962 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 963 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 964 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 965 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 966 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 967 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 968 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 970 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 971 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 972 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 973 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 974 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 975 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 976 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 977 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 978 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 979 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 982 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 983 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 984 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 985 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 986 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 987 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi;
va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax;
va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 2317,
"start_col": 0,
"start_line": 2145
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE:quad32 ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode
unit (va_code_Gcm_blocks128 alg)) =
(va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10;
va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64
rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem])
(va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)
(va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE))
//--
//-- Gcm_blocks
#push-options "--z3rlimit 1000"
val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks alg offset =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64
32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp)
(offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13))
(va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb
(va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)
(va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64
rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi)
(va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons
(va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg)
(va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14)
(va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64
(va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse
(va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons
(va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons
(va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block
(va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15))
(va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ()))
(va_CNil ()))))))))))))))))))))))))))))))))))))
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)
(va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64
rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and
(va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp)
(offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx)
(va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public)
(va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and
(va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd
(va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and
(va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret)
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax)
(va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14)
(va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9)
(va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11)
(va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and
(va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64
(va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public))
(va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13)
(va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10)
(va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10)
(va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and
(va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register
()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and
(va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gcm_blocks alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_old_s)) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 463 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 464 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 465 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 466 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_auth auth_b abytes_b hkeys_b h_LE) (fun (va_s:va_state)
(auth_quad_seq:(seq quad32)) -> let (y_0:quad32) = Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0 in let (y_auth_bytes:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 473 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 474 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 475 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 476 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 477 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> let
(iv_BE:Vale.X64.Decls.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32
iv_BE 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 483 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public iv_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 485 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp)
(va_op_xmm_xmm 1) 0 Secret scratch_b 0) (fun (va_s:va_state) _ -> let (j0:quad32) = va_get_xmm
1 va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 487 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load_one_lsb (va_op_xmm_xmm 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 489 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 491 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AES_GCM_decrypt_6mult alg h_LE iv_b in128x6_b out128x6_b scratch_b key round_keys
keys_b hkeys_b) (fun (va_s:va_state) _ -> let (y_cipher128x6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (auth_in:(seq quad32)) =
auth_quad_seq in let (va_arg138:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in let
(va_arg137:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg136:Vale.Def.Types_s.quad32) = y_auth_bytes in let (va_arg135:Vale.Def.Types_s.quad32) =
y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 494 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg135 va_arg136
y_cipher128x6 va_arg137 va_arg138) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 498 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11)
(va_op_reg_opr64_reg64 rRbp) 32 Secret scratch_b 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 499 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 500 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 501 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 502 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 504 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 505 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 506 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks128 alg in128_b out128_b key round_keys keys_b hkeys_b h_LE) (fun
(va_s:va_state) _ -> let (y_cipher128:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (va_arg134:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b in let
(va_arg133:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg132:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 508 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg132 y_cipher128x6
y_cipher128 va_arg133 va_arg134) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Stack_lemma (va_op_reg64_reg64 rRsp) (offset + 24) Public) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp)
(offset + 24) Public)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 513 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 514 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64))
(fun (va_s:va_state) _ -> let (y_inout:Vale.Def.Types_s.quad32) = y_cipher128 in let
(plain_byte_seq:(seq quad32)) = empty_seq_quad32 in let (cipher_byte_seq:(seq quad32)) =
empty_seq_quad32 in let (va_arg131:Vale.Def.Types_s.quad32) = va_get_xmm 11 va_s in let
(va_arg130:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg129:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg128:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg127:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 519 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_opaque_init va_arg127 va_arg128 va_arg129 va_arg130
va_arg131) (let (total_bytes:(va_int_at_least 0)) = FStar.Seq.Base.length #quad32 auth_quad_seq
`op_Multiply` 16 + plain_num_bytes in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 523 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qIf va_mods (Cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 525 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (fun (va_s:va_state) _
-> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 527 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 528 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 532 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes y_0 auth_in
h_LE) (fun (va_s:va_state) _ -> let y_inout = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm
8 va_s) in let (raw_auth_quads:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.append #quad32
auth_in (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 536 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 total_bytes)
(fun _ -> let (auth_input_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
raw_auth_quads) 0 total_bytes in let (padded_auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let auth_in =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let plain_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let cipher_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QEmpty ((auth_in,
cipher_byte_seq, plain_byte_seq, y_inout)))))))))) (qblock va_mods (fun (va_s:va_state) ->
va_QEmpty ((auth_in, cipher_byte_seq, plain_byte_seq, y_inout))))) (fun (va_s:va_state) va_g ->
let ((auth_in:(seq quad32)), (cipher_byte_seq:(seq quad32)), (plain_byte_seq:(seq quad32)),
(y_inout:Vale.Def.Types_s.quad32)) = va_g in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 547 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 548 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_make_length_quad ()) (fun (va_s:va_state) _ -> let
(length_quad32:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 0
va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 551 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_register hkeys_b h_LE y_inout) (fun (va_s:va_state) _ -> let
(y_final:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 554 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret scratch_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 557 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_register alg key round_keys keys_b) (fun (va_s:va_state) _ -> let
(va_arg126:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 560 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton va_arg126)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (icb_BE_677:Vale.Def.Types_s.quad32) (plain_LE_678:Vale.Def.Types_s.quad32)
(alg_679:Vale.AES.AES_common_s.algorithm) (key_680:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(i_681:Prims.int) -> Vale.AES.AES_s.is_aes_key_LE alg_679 key_680) j0 y_final alg key 0) (fun _
-> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_s == Vale.AES.GCTR_s.gctr_encrypt_block j0 y_final alg key 0) (let
(plain128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let
(cipher128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) in128_b) in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 566 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 plain_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 plain128 plain_byte_seq)
plain128) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 567 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 cipher_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 cipher128 cipher_byte_seq)
cipher128) (let (va_arg125:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite ctr_BE_2 len128x6
in let (va_arg124:Vale.Def.Types_s.quad32) = ctr_BE_2 in let (va_arg123:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg122:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32))
= Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg121:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg120:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b in let
(va_arg119:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_old_s) in128x6_b in let (va_arg118:Prims.nat) = len128 in let
(va_arg117:Prims.nat) = len128x6 in let (va_arg116:Vale.AES.AES_common_s.algorithm) = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 569 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg116 va_arg117 va_arg118
va_arg119 va_arg120 va_arg121 va_arg122 va_arg123 va_arg124 va_arg125) (let
(va_arg115:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite (Vale.AES.GCTR.inc32lite ctr_BE_2
len128x6) len128 in let (va_arg114:Vale.Def.Types_s.quad32) = ctr_BE_2 in let
(va_arg113:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg112:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg111:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg110:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b) in let
(va_arg109:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let (va_arg108:Prims.nat) =
FStar.Seq.Base.length #quad32 plain_byte_seq in let (va_arg107:Prims.nat) = len128x6 + len128
in let (va_arg106:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 575 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg106 va_arg107 va_arg108
va_arg109 va_arg110 va_arg111 va_arg112 va_arg113 va_arg114 va_arg115) (let
(va_arg105:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg104:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 583 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hash_append2 h_LE va_arg104 y_inout y_final va_arg105
length_quad32) (let auth_in = FStar.Seq.Base.append #quad32 auth_in (FStar.Seq.Base.create
#Vale.Def.Types_s.quad32 1 length_quad32) in let (va_arg103:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = auth_in in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 585 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.ghash_incremental_to_ghash h_LE va_arg103) (va_QEmpty
(()))))))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks alg offset) va_s0 /\ va_get_ok va_s0 /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) else FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = (if (plain_num_bytes
> (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) else
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) in let
(cipher_bound:nat) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division`
8) then (len128x6 + len128 + 1) else (len128x6 + len128)) in Vale.AES.GCTR.gctr_partial alg
cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let (length_quad:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = (if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b) else Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in let
(padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let
(auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let
(raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat) =
FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then (let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) else
raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks alg offset) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 396 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 397 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 398 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 399 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 400 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 404 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_1:quad32) = iv_BE in label va_range1
"***** POSTCONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 412 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 421 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_out:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 430 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 + len128) in label
va_range1
"***** POSTCONDITION NOT MET AT line 434 column 77 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 438 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0) (8 `op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply`
plain_num_bytes) 0) in label va_range1
"***** POSTCONDITION NOT MET AT line 440 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 444 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 446 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in label va_range1
"***** POSTCONDITION NOT MET AT line 448 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 452 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (total_bytes:nat) = FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 +
plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 453 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply`
128 `op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let
(pb:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32
pb) (fun _ -> raw_quad_seq) in label va_range1
"***** POSTCONDITION NOT MET AT line 460 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in label va_range1
"***** POSTCONDITION NOT MET AT line 461 column 106 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE
h_LE auth_quad_seq) alg key 0)))))))))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in sse_enabled /\
movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = va_if
(plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) (fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM)
inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) in let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128)
`op_Multiply` 128 `op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 +
len128) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let
(length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64
rRsi va_s0) in let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits
auth_input_bytes in let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32
padded_auth_bytes in let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32 auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0)
in128x6_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat)
= FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) (fun
_ -> raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
raw_quad_seq (FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks : alg:algorithm -> offset:int -> auth_b:buffer128 -> abytes_b:buffer128
-> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 -> out128_b:buffer128 ->
inout_b:buffer128 -> iv_b:buffer128 -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks alg offset) ([va_Mod_flags;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks (va_code_Gcm_blocks alg offset) va_s0 alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gcm_blocks alg
offset)) =
(va_QProc (va_code_Gcm_blocks alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b) (va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b))
#pop-options
//--
//-- Gcm_blocks_wrapped
#push-options "--z3rlimit 60"
val va_code_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_wrapped alg offset =
(va_Block (va_CCons (va_code_Gcm_blocks alg offset) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CNil ())))))
val va_codegen_success_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_wrapped alg offset =
(va_pbool_and (va_codegen_success_Gcm_blocks alg offset) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks_wrapped (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 739 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b) (fun (va_s:va_state) _ -> va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(8 `op_Multiply` va_get_reg64 rRsi va_old_s >= 0 /\ 8 `op_Multiply` va_get_reg64 rRsi va_old_s
<= 18446744073709551615 /\ 8 `op_Multiply` plain_num_bytes >= 0 /\ 8 `op_Multiply`
plain_num_bytes <= 18446744073709551615) (fun _ -> let (va_arg55:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_old_s) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(va_arg54:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in let
(va_arg53:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s)) in let
(va_arg52:Vale.Def.Types_s.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (va_arg51:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg50:Prims.nat) =
va_get_reg64 rRsi va_old_s in let (va_arg49:Prims.nat) = plain_num_bytes in let
(va_arg48:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg47:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg46:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg45:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg44:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg43:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg42:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_old_s) abytes_b in let (va_arg41:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b in let
(va_arg40:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg39:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_dec_helper_simplified va_arg39 va_arg40 va_arg41
va_arg42 va_arg43 va_arg44 va_arg45 va_arg46 va_arg47 va_arg48 va_arg49 va_arg50 va_arg51
va_arg52 va_arg53 va_arg54 va_arg55) (let (auth_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s)
abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 751 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64
rRsi va_old_s)) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_old_s) in let (va_arg38:Vale.Def.Types_s.quad32) =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_old_s) in let
(va_arg37:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg36:Prims.nat) = plain_num_bytes in
let (va_arg35:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = expected_tag in let
(va_arg34:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = auth_bytes in let
(va_arg33:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg32:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg31:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg30:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg29:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg28:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg27:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg26:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 752 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_helper_dec_simplified va_arg26 va_arg27 va_arg28
va_arg29 va_arg30 va_arg31 va_arg32 va_arg33 va_arg34 va_arg35 va_arg36 va_arg37 va_arg38)
(va_QEmpty (()))))))))
val va_lemma_Gcm_blocks_wrapped : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
iv:supported_iv_LE -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> hkeys_b:buffer128 -> expected_tag:(seq nat8)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_wrapped alg offset) va_s0 /\ va_get_ok
va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet
5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1
va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12
va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM
(va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks_wrapped va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks_wrapped va_mods alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks_wrapped alg offset) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 588 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 711 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 712 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 713 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 714 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 715 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 718 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 719 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 721 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 723 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0)
abytes_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 724 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 725 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 726 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 727 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 728 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 737 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 plain_bytes < pow2_32)) (cipher_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
plain_bytes auth_bytes expected_tag))) (Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8
va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key) iv plain_bytes auth_bytes))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks_wrapped (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (expected_tag:(seq nat8))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
sse_enabled /\ movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) auth_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6
va_s0) in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1
va_s0) in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) out128_ptr out128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5
va_s0) inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0)
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) ==> va_k
va_sM (())))
val va_wpProof_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> auth_b:buffer128 ->
abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 ->
out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> expected_tag:(seq nat8) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b
out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_wrapped alg offset)
([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b
inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks_wrapped (va_code_Gcm_blocks_wrapped alg offset) va_s0
alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key
round_keys keys_b hkeys_b expected_tag in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks_wrapped (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(va_QProc (va_code_Gcm_blocks_wrapped alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks_wrapped alg offset
auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys
keys_b hkeys_b expected_tag) (va_wpProof_Gcm_blocks_wrapped alg offset auth_b abytes_b
in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag))
#pop-options
//--
//-- Gcm_blocks_decrypt_stdcall
#push-options "--z3rlimit 1600"
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_decrypt_stdcall win alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_code_Save_registers win) (va_CCons (if win then va_Block (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 0)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 8))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (224
+ 40 + 88)) (va_CNil ())))))))) else va_Block (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (64 + 8 + 72)) (va_CNil ())))
(va_CCons (va_code_Gcm_blocks_wrapped alg (Vale.X64.Decls.total_if #int win (224 + 56) (64 +
8))) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rR15) (va_op_reg_opr64_reg64 rRsp)
(Vale.X64.Decls.total_if #int win (224 + 40 + 96) (64 + 8 + 80))) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rR15) 0 Secret) (va_CCons (va_code_XmmEqual (va_op_xmm_xmm 0) (va_op_xmm_xmm 8)) (va_CCons
(va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Restore_registers
win) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons
(va_code_DestroyHeaplets ()) (va_CNil ()))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_decrypt_stdcall win alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and
(va_codegen_success_Save_registers win) (va_pbool_and (if win then va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR9)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsp) (224
+ 40 + 0)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR9)
(va_op_reg_opr64_reg64 rRsp) (224 + 40 + 8)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 88)) (va_ttrue ())))))))
else va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRbp)
(va_op_reg_opr64_reg64 rRsp) (64 + 8 + 72)) (va_ttrue ())) (va_pbool_and
(va_codegen_success_Gcm_blocks_wrapped alg (Vale.X64.Decls.total_if #int win (224 + 56) (64 +
8))) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR15)
(va_op_reg_opr64_reg64 rRsp) (Vale.X64.Decls.total_if #int win (224 + 40 + 96) (64 + 8 + 80)))
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm
0) (va_op_reg_opr64_reg64 rR15) 0 Secret) (va_pbool_and (va_codegen_success_XmmEqual
(va_op_xmm_xmm 0) (va_op_xmm_xmm 8)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_pbool_and
(va_codegen_success_Restore_registers win) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks_decrypt_stdcall (va_mods:va_mods_t) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128)
(key:(seq nat32)) : (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s)
(fun _ -> va_get_reg64 rRdi va_s) in let (auth_num_bytes:(va_int_range 0 18446744073709551615))
= va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let
(auth_len:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s)
(fun _ -> va_get_reg64 rRdx va_s) in let (keys_ptr:(va_int_range 0 18446744073709551615)) =
va_if win (fun _ -> va_get_reg64 rR9 va_s) (fun _ -> va_get_reg64 rRcx va_s) in let
(iv_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 32 + 8 + 0) (va_get_stack va_s)) (fun _
-> va_get_reg64 rR8 va_s) in let (xip:(va_int_range 0 18446744073709551615)) = va_if win (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 32 + 8 + 8) (va_get_stack va_s))
(fun _ -> va_get_reg64 rR9 va_s) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) =
va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 16)
(va_get_stack va_s)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 0)
(va_get_stack va_s)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win
(fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 24) (va_get_stack va_s))
(fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 8) (va_get_stack va_s))
in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 32) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 16) (va_get_stack va_s)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 40) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 24) (va_get_stack va_s)) in let
(in128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 48) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 32) (va_get_stack va_s)) in let
(out128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 56) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 40) (va_get_stack va_s)) in let
(len128:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 64) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 48) (va_get_stack va_s)) in let
(inout_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 72) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 56) (va_get_stack va_s)) in let
(cipher_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 80) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 64) (va_get_stack va_s)) in let
(scratch_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 88) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 72) (va_get_stack va_s)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 96) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 80) (va_get_stack va_s)) in
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 989 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 auth_b 1 Secret Immutable; declare_buffer128
abytes_b 7 Secret Immutable; declare_buffer128 in128x6_b 6 Secret Immutable; declare_buffer128
in128_b 1 Secret Immutable; declare_buffer128 hkeys_b 0 Secret Immutable; declare_buffer128
tag_b 0 Secret Immutable; declare_buffer128 keys_b 0 Secret Immutable; declare_buffer128 iv_b 2
Public Mutable; declare_buffer128 scratch_b 3 Secret Mutable; declare_buffer128 out128x6_b 6
Secret Mutable; declare_buffer128 out128_b 1 Secret Mutable; declare_buffer128 inout_b 5 Secret
Mutable])) (fun (va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1003 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (alg_10639:Vale.AES.AES_common_s.algorithm) (key_10640:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_LE_10641:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_s.is_aes_key_LE alg_10639 key_10640) alg key (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0)) (fun _ -> let (va_arg69:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in let (va_arg68:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s) hkeys_b in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 1003 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hkeys_reqs_pub_priv va_arg68 va_arg69) (va_qAssert
va_range1
"***** PRECONDITION NOT MET AT line 1004 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 40) (va_get_stack va_s))
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1005 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 80) (va_get_stack va_s))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1006 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Save_registers win) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1009 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1011 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1012 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1013 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1014 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR9)) (fun (va_s:va_state) _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1015 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_s + 224 == va_get_reg64 rRsp va_old_s) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1016 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 224 + 40) (va_get_stack va_s))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1017 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 0))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1018 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1019 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (224 + 40 +
88)) (va_QEmpty (())))))))))))) (qblock va_mods (fun (va_s:va_state) -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1023 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_s + 64 == va_get_reg64 rRsp va_old_s) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1024 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 64 + 80) (va_get_stack va_s))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1025 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (64 + 8 + 72))
(va_QEmpty (()))))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1028 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_wrapped alg (Vale.X64.Decls.total_if #int win (224 + 56) (64 + 8)) auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key
(Vale.X64.Decls.buffer128_as_seq (va_get_mem_heaplet 0 va_old_s) keys_b) keys_b hkeys_b
(Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem_heaplet
0 va_old_s)))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1048 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR15) (va_op_reg_opr64_reg64 rRsp)
(Vale.X64.Decls.total_if #int win (224 + 40 + 96) (64 + 8 + 80))) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1049 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rR15) 0 Secret tag_b 0) (fun (va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1050 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 0 va_s == Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem_heaplet 0 va_s))
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1051 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 0 va_s == Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem_heaplet 0 va_old_s))
(let (alleged_tag_quad:quad32) = va_get_xmm 0 va_s in let (computed_tag:quad32) = va_get_xmm 8
va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1054 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_XmmEqual (va_op_xmm_xmm 0) (va_op_xmm_xmm 8)) (fun (va_s:va_state) _ -> let
(auth_raw_quads:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s) abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1057 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 auth_num_bytes in let (cipher_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1059 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0
cipher_num_bytes) (fun _ -> let (cipher_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 cipher_num_bytes in let (va_arg67:Vale.Def.Types_s.quad32) = computed_tag
in let (va_arg66:Vale.Def.Types_s.quad32) = alleged_tag_quad in let
(va_arg65:Vale.Def.Words_s.nat64) = va_get_reg64 rRax va_s in let (va_arg64:(FStar.Seq.Base.seq
Vale.Def.Words_s.nat8)) = auth_bytes in let (va_arg63:(FStar.Seq.Base.seq
Vale.Def.Words_s.nat8)) = cipher_bytes in let (va_arg62:Vale.AES.GCM_s.supported_iv_LE) = iv in
let (va_arg61:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) =
Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key in let
(va_arg60:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 1060 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.decrypt_helper va_arg60 va_arg61 va_arg62 va_arg63 va_arg64
va_arg65 va_arg66 va_arg67) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1066 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1067 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Restore_registers win (va_get_reg64 rRsp va_old_s) (va_get_xmm 6 va_old_s)
(va_get_xmm 7 va_old_s) (va_get_xmm 8 va_old_s) (va_get_xmm 9 va_old_s) (va_get_xmm 10
va_old_s) (va_get_xmm 11 va_old_s) (va_get_xmm 12 va_old_s) (va_get_xmm 13 va_old_s)
(va_get_xmm 14 va_old_s) (va_get_xmm 15 va_old_s)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1068 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1070 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))))))))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 1600,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
win: Prims.bool ->
alg: Vale.AES.AES_common_s.algorithm ->
auth_b: Vale.X64.Memory.buffer128 ->
auth_bytes: Vale.X64.Memory.nat64 ->
auth_num: Vale.X64.Memory.nat64 ->
keys_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
hkeys_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
len128x6_num: Vale.X64.Memory.nat64 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
len128_num: Vale.X64.Memory.nat64 ->
inout_b: Vale.X64.Memory.buffer128 ->
cipher_num: Vale.X64.Memory.nat64 ->
scratch_b: Vale.X64.Memory.buffer128 ->
tag_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Prims.bool",
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Memory.buffer128",
"Vale.X64.Memory.nat64",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_stackTaint",
"Vale.X64.QuickCode.va_Mod_stack",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_layout",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_ok",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.X64.QuickCode.__proj__QProc__item__mods",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.X64.State.vale_state",
"Vale.X64.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.X64.QuickCodes.label",
"Vale.X64.QuickCodes.va_range1",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.Decls.modifies_mem",
"Vale.X64.Decls.loc_union",
"Vale.X64.Decls.loc_buffer",
"Vale.X64.Memory.vuint128",
"Vale.X64.Decls.va_get_mem",
"Prims.op_LessThan",
"Vale.X64.Machine_s.pow2_32",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat8",
"Vale.AES.AES_common_s.is_aes_key",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"FStar.Pervasives.Native.__proj__Mktuple2__item___1",
"Vale.AES.GCM_s.gcm_decrypt_LE",
"Prims.op_Equality",
"Prims.int",
"Vale.X64.Decls.va_get_reg64",
"FStar.Pervasives.Native.__proj__Mktuple2__item___2",
"Vale.Def.Types_s.nat64",
"Prims.l_imp",
"Vale.X64.Decls.quad32",
"Vale.X64.Decls.va_get_xmm",
"Prims.l_not",
"Vale.Def.Words_s.nat8",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.X64.Decls.buffer128_read",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.append",
"Vale.X64.Decls.s128",
"Vale.X64.Decls.va_int_range",
"Vale.X64.Decls.va_if",
"Vale.X64.Stack_i.load_stack64",
"Prims.op_Addition",
"Vale.X64.Decls.va_get_stack",
"Vale.X64.QuickCode.quickCode",
"Vale.AES.X64.GCMdecryptOpt.va_qcode_Gcm_blocks_decrypt_stdcall"
] | [] | false | false | false | false | false | let va_lemma_Gcm_blocks_decrypt_stdcall
va_b0
va_s0
win
alg
auth_b
auth_bytes
auth_num
keys_b
iv_b
iv
hkeys_b
abytes_b
in128x6_b
out128x6_b
len128x6_num
in128_b
out128_b
len128_num
inout_b
cipher_num
scratch_b
tag_b
key
=
| let va_mods:va_mods_t =
[
va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3;
va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14;
va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9;
va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok;
va_Mod_mem
]
in
let va_qc =
va_qcode_Gcm_blocks_decrypt_stdcall va_mods win alg auth_b auth_bytes auth_num keys_b iv_b iv
hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b
cipher_num scratch_b tag_b key
in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_Gcm_blocks_decrypt_stdcall win alg)
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 764 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\
(let auth_ptr:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0)
in
let auth_num_bytes:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0)
in
let auth_len:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0)
in
let keys_ptr:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64 rRcx va_s0)
in
let iv_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0)
(va_get_stack va_s0))
(fun _ -> va_get_reg64 rR8 va_s0)
in
let xip:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8)
(va_get_stack va_s0))
(fun _ -> va_get_reg64 rR9 va_s0)
in
let abytes_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0)
(va_get_stack va_s0))
in
let in128x6_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8)
(va_get_stack va_s0))
in
let out128x6_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16)
(va_get_stack va_s0))
in
let len128x6:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24)
(va_get_stack va_s0))
in
let in128_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32)
(va_get_stack va_s0))
in
let out128_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40)
(va_get_stack va_s0))
in
let len128:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48)
(va_get_stack va_s0))
in
let inout_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56)
(va_get_stack va_s0))
in
let cipher_num_bytes:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64)
(va_get_stack va_s0))
in
let scratch_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72)
(va_get_stack va_s0))
in
let tag_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96)
(va_get_stack va_s0))
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80)
(va_get_stack va_s0))
in
label va_range1
"***** POSTCONDITION NOT MET AT line 931 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
iv_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
scratch_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
out128x6_b)
(Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
out128_b)
(Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b)))))
(va_get_mem va_s0)
(va_get_mem va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 934 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(cipher_num_bytes < pow2_32) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 935 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(auth_num_bytes < pow2_32) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 937 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 939 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 940 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
auth_num_bytes
in
label va_range1
"***** POSTCONDITION NOT MET AT line 941 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b))
(Vale.X64.Decls.s128 (va_get_mem va_s0) inout_b)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 942 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads)
0
cipher_num_bytes
in
label va_range1
"***** POSTCONDITION NOT MET AT line 943 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem va_sM) out128_b))
(Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 944 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads)
0
cipher_num_bytes
in
label va_range1
"***** POSTCONDITION NOT MET AT line 945 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let expected_tag =
Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read
tag_b
0
(va_get_mem va_s0))
in
label va_range1
"***** POSTCONDITION NOT MET AT line 955 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes <
pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8
cipher_bytes <
pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key)))
(plain_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)
#bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key)
iv
cipher_bytes
auth_bytes
expected_tag)))
(va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8
)
#bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key)
iv
cipher_bytes
auth_bytes
expected_tag))) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 958 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 961 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==>
va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 962 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==>
va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 963 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==>
va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 964 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==>
va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 965 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==>
va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 966 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==>
va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 967 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==>
va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 968 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 970 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 971 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 972 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 973 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 974 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 975 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 976 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 977 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 978 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 979 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 982 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==>
va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 983 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==>
va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 984 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==>
va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 985 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==>
va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 986 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==>
va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 987 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==>
va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))))
)))))))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4;
va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14;
va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9;
va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok;
va_Mod_mem
])
va_sM
va_s0;
(va_sM, va_fM) | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.row_v | val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) | val row_v: #a:Spec.alg -> #m:m_spec -> h:mem -> row_p a m -> GTot (Spec.row a) | let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 30,
"start_col": 0,
"start_line": 25
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> r: Hacl.Impl.Blake2.Core.row_p a m
-> Prims.GTot (Spec.Blake2.Definitions.row a) | Prims.GTot | [
"sometrivial"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Blake2.Core.row_p",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntVector.vec_v",
"Spec.Blake2.Definitions.wt",
"Lib.Sequence.index",
"Hacl.Impl.Blake2.Core.element_t",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Blake2.Core.row_len",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.Pervasives.Native.tuple2",
"Spec.Blake2.Definitions.row"
] | [] | false | false | false | false | false | let row_v #a #m h r =
| match a, m with
| Spec.Blake2S, M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S, M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B, M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.g_rowi_disjoint_other | val g_rowi_disjoint_other: #a:Spec.alg -> #m:m_spec -> #b:Type -> st:state_p a m -> i:index_t -> x:buffer b ->
Lemma(requires (disjoint st x))
(ensures (disjoint (g_rowi st i) x))
[SMTPat (disjoint (g_rowi st i) x)] | val g_rowi_disjoint_other: #a:Spec.alg -> #m:m_spec -> #b:Type -> st:state_p a m -> i:index_t -> x:buffer b ->
Lemma(requires (disjoint st x))
(ensures (disjoint (g_rowi st i) x))
[SMTPat (disjoint (g_rowi st i) x)] | let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m)) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 86,
"start_col": 0,
"start_line": 83
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m)) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_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.Blake2.Core.state_p a m -> i: Hacl.Impl.Blake2.Core.index_t -> x: Lib.Buffer.buffer b
-> FStar.Pervasives.Lemma (requires Lib.Buffer.disjoint st x)
(ensures Lib.Buffer.disjoint (Hacl.Impl.Blake2.Core.g_rowi st i) x)
[SMTPat (Lib.Buffer.disjoint (Hacl.Impl.Blake2.Core.g_rowi st i) x)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Hacl.Impl.Blake2.Core.state_p",
"Hacl.Impl.Blake2.Core.index_t",
"Lib.Buffer.buffer",
"LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r'",
"Hacl.Impl.Blake2.Core.element_t",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Blake2.Core.row_len",
"Prims.unit",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.Buffer.length",
"Lib.Buffer.MUT"
] | [] | true | false | true | false | false | let g_rowi_disjoint_other #a #m #b st i x =
| assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_
#(LowStar.Buffer.trivial_preorder (element_t a m))
#(LowStar.Buffer.trivial_preorder (element_t a m))
st
(i *. row_len a m)
(row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m)) | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.modifies_one_row | val modifies_one_row: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> j:index_t ->
Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1 /\ v i <> v j))
(ensures (row_v h1 (g_rowi st j) == row_v h0 (g_rowi st j)))
[SMTPat (modifies (loc (g_rowi st i)) h0 h1); SMTPat (row_v h1 (g_rowi st j))] | val modifies_one_row: a:Spec.alg -> m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t -> j:index_t ->
Lemma (requires (live h0 st /\ modifies (loc (g_rowi st i)) h0 h1 /\ v i <> v j))
(ensures (row_v h1 (g_rowi st j) == row_v h0 (g_rowi st j)))
[SMTPat (modifies (loc (g_rowi st i)) h0 h1); SMTPat (row_v h1 (g_rowi st j))] | let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 126,
"start_col": 0,
"start_line": 119
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = () | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_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.Blake2.Definitions.alg ->
m: Hacl.Impl.Blake2.Core.m_spec ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
st: Hacl.Impl.Blake2.Core.state_p a m ->
i: Hacl.Impl.Blake2.Core.index_t ->
j: Hacl.Impl.Blake2.Core.index_t
-> FStar.Pervasives.Lemma
(requires
Lib.Buffer.live h0 st /\
Lib.Buffer.modifies (Lib.Buffer.loc (Hacl.Impl.Blake2.Core.g_rowi st i)) h0 h1 /\
Lib.IntTypes.v i <> Lib.IntTypes.v j)
(ensures
Hacl.Impl.Blake2.Core.row_v h1 (Hacl.Impl.Blake2.Core.g_rowi st j) ==
Hacl.Impl.Blake2.Core.row_v h0 (Hacl.Impl.Blake2.Core.g_rowi st j))
[
SMTPat (Lib.Buffer.modifies (Lib.Buffer.loc (Hacl.Impl.Blake2.Core.g_rowi st i)) h0 h1);
SMTPat (Hacl.Impl.Blake2.Core.row_v h1 (Hacl.Impl.Blake2.Core.g_rowi st j))
] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Blake2.Core.state_p",
"Hacl.Impl.Blake2.Core.index_t",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Hacl.Impl.Blake2.Core.element_t",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Blake2.Core.row_len",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Lib.Buffer.live",
"Lib.Buffer.lbuffer_t",
"Hacl.Impl.Blake2.Core.g_rowi"
] | [] | true | false | true | false | false | let modifies_one_row a m h0 h1 st i j =
| let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj) | false |
Vale.Stdcalls.X64.Fadd.fsti | Vale.Stdcalls.X64.Fadd.uint64 | val uint64 : Prims.eqtype | let uint64 = UInt64.t | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 31,
"start_col": 0,
"start_line": 31
} | module Vale.Stdcalls.X64.Fadd
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
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 FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide | {
"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.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fadd.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"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": "FStar.Mul",
"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": 50,
"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 |
|
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.copy_state | val copy_state: #a:Spec.alg -> #m:m_spec -> st2:state_p a m -> st1:state_p a m ->
Stack unit
(requires (fun h0 -> live h0 st1 /\ live h0 st2 /\ disjoint st1 st2))
(ensures (fun h0 r h1 -> modifies (loc st2) h0 h1 /\
state_v h1 st2 == state_v h0 st1)) | val copy_state: #a:Spec.alg -> #m:m_spec -> st2:state_p a m -> st1:state_p a m ->
Stack unit
(requires (fun h0 -> live h0 st1 /\ live h0 st2 /\ disjoint st1 st2))
(ensures (fun h0 r h1 -> modifies (loc st2) h0 h1 /\
state_v h1 st2 == state_v h0 st1)) | let copy_state #a #m st2 st1 =
copy #_ #_ #(le_sigh a m) st2 st1 | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 304,
"start_col": 0,
"start_line": 303
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200"
noextract inline_for_extraction
let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1
#pop-options
#push-options "--z3rlimit 50"
noextract inline_for_extraction
let permr_row #a #m r1 n =
[@inline_let]
let n0 = n in
[@inline_let]
let n1 = (n+.1ul)%.4ul in
[@inline_let]
let n2 = (n+.2ul)%.4ul in
[@inline_let]
let n3 = (n+.3ul)%.4ul in
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
let v0 : vec_t U32 4 = r1.(0ul) in
let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| Spec.Blake2B,M256 ->
let v0 : vec_t U64 4 = r1.(0ul) in
let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| _ ->
let h0 = ST.get() in
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
let x0 = r1.(n0) in
let x1 = r1.(n1) in
let x2 = r1.(n2) in
let x3 = r1.(n3) in
r1.(0ul) <- x0;
r1.(1ul) <- x1;
r1.(2ul) <- x2;
r1.(3ul) <- x3;
let h1 = ST.get() in
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4])));
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4]))));
Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3));
()
#pop-options
#push-options "--z3rlimit 50"
let create4_lemma #a x0 x1 x2 x3 =
let open Lib.Sequence in
let l : list a = [x0;x1;x2;x3] in
assert_norm (List.Tot.length l = 4);
let s1 : lseq a 4 = of_list l in
let s2 : lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2
#pop-options
noextract inline_for_extraction
let alloc_row a m = create (row_len a m) (zero_element a m)
noextract inline_for_extraction
let create_row #a #m r w0 w1 w2 w3 =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128
| Spec.Blake2B,M256 ->
r.(0ul) <- vec_load4 w0 w1 w2 w3
| _ ->
r.(0ul) <- w0;
r.(1ul) <- w1;
r.(2ul) <- w2;
r.(3ul) <- w3;
let h1 = ST.get() in
Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3)
noextract inline_for_extraction
let load_row #a #m r ws = create_row r ws.(0ul) ws.(1ul) ws.(2ul) ws.(3ul)
noextract inline_for_extraction
let store_row #a #m b r =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
vec_store_le #U32 #4 b r.(0ul)
| Spec.Blake2B,M256 ->
vec_store_le #U64 #4 b r.(0ul)
| _ ->
uints_to_bytes_le #(Spec.wt a) 4ul b r
noextract inline_for_extraction
let store_row32 #a #m b r =
push_frame();
let h0 = ST.get() in
let b8 = create (size_row a) (u8 0) in
store_row b8 r;
let h1 = ST.get() in
uints_from_bytes_le b b8;
let h2 = ST.get() in
assert (as_seq h1 b8 == Lib.ByteSequence.uints_to_bytes_le #(Spec.wt a) (row_v h0 r));
assert (as_seq h2 b == Lib.ByteSequence.uints_from_bytes_le #(Spec.wt a) (as_seq h1 b8));
Lib.Sequence.eq_intro (as_seq h2 b) (Spec.load_row (as_seq h2 b));
assert (Spec.load_row (as_seq h2 b) ==
Lib.ByteSequence.uints_from_bytes_le (as_seq h1 b8));
Lib.ByteSequence.lemma_uints_to_from_bytes_le_preserves_value (row_v h0 r);
pop_frame()
noextract inline_for_extraction
let gather_row #a #ms r m i0 i1 i2 i3 =
create_row r m.(i0) m.(i1) m.(i2) m.(i3)
noextract inline_for_extraction
let le_sigh (a:Spec.alg) (m:m_spec): x:size_t { x == 4ul *. row_len a m } =
let open FStar.Mul in
assert_norm ((4 * 1) % pow2 32 = 4);
assert_norm ((4 * 4) % pow2 32 = 16);
Lib.IntTypes.mul_mod_lemma 4ul 1ul;
Lib.IntTypes.mul_mod_lemma 4ul 4ul;
match a,m with
| Spec.Blake2S,M128 -> 4ul
| Spec.Blake2S,M256 -> 4ul
| Spec.Blake2B,M256 -> 4ul
| _ -> 16ul
noextract inline_for_extraction
let alloc_state a m =
// See git blame below. I never managed to get the previous expression (4ul *.
// row_len a m) to reduce, which generated VLAs in the C code.
create (le_sigh a m) (zero_element a m) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | st2: Hacl.Impl.Blake2.Core.state_p a m -> st1: Hacl.Impl.Blake2.Core.state_p a m
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Hacl.Impl.Blake2.Core.state_p",
"Lib.Buffer.copy",
"Lib.Buffer.MUT",
"Hacl.Impl.Blake2.Core.element_t",
"Hacl.Impl.Blake2.Core.le_sigh",
"Prims.unit"
] | [] | false | true | false | false | false | let copy_state #a #m st2 st1 =
| copy #_ #_ #(le_sigh a m) st2 st1 | false |
Vale.Stdcalls.X64.Fadd.fsti | Vale.Stdcalls.X64.Fadd.tuint64 | val tuint64 : Vale.Interop.Base.td | let tuint64 = TD_Base TUInt64 | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 46,
"start_col": 0,
"start_line": 46
} | module Vale.Stdcalls.X64.Fadd
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
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 FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
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 b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({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.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fadd.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"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": "FStar.Mul",
"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": 50,
"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.Fadd.fsti | Vale.Stdcalls.X64.Fadd.t64_no_mod | val t64_no_mod : Vale.Interop.Base.td | let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 105,
"end_line": 44,
"start_col": 0,
"start_line": 44
} | module Vale.Stdcalls.X64.Fadd
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
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 FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
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 b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 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.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fadd.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"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": "FStar.Mul",
"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": 50,
"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.TUInt64",
"Vale.Interop.Base.Mkbuffer_qualifiers",
"Vale.Arch.HeapTypes_s.Secret"
] | [] | false | false | false | true | false | let t64_no_mod =
| TD_Buffer TUInt64 TUInt64 ({ modified = false; strict_disjointness = false; taint = MS.Secret }) | false |
|
Vale.Stdcalls.X64.Fadd.fsti | Vale.Stdcalls.X64.Fadd.t64_mod | val t64_mod : Vale.Interop.Base.td | let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 42,
"start_col": 0,
"start_line": 42
} | module Vale.Stdcalls.X64.Fadd
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
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 FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
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 b64 = buf_t TUInt64 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.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fadd.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"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": "FStar.Mul",
"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": 50,
"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.TUInt64",
"Vale.Interop.Base.default_bq"
] | [] | false | false | false | true | false | let t64_mod =
| TD_Buffer TUInt64 TUInt64 default_bq | false |
|
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.rowi | val rowi: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx:index_t ->
Stack (row_p a m)
(requires (fun h -> live h st))
(ensures (fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == g_rowi st idx)) | val rowi: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx:index_t ->
Stack (row_p a m)
(requires (fun h -> live h st))
(ensures (fun h0 r h1 -> h0 == h1 /\ live h1 r /\ r == g_rowi st idx)) | let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 135,
"start_col": 0,
"start_line": 134
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | st: Hacl.Impl.Blake2.Core.state_p a m -> idx: Hacl.Impl.Blake2.Core.index_t
-> FStar.HyperStack.ST.Stack (Hacl.Impl.Blake2.Core.row_p a m) | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Hacl.Impl.Blake2.Core.state_p",
"Hacl.Impl.Blake2.Core.index_t",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Hacl.Impl.Blake2.Core.element_t",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Blake2.Core.row_len",
"Lib.Buffer.lbuffer_t",
"Hacl.Impl.Blake2.Core.row_p"
] | [] | false | true | false | false | false | let rowi (#a: Spec.alg) (#m: m_spec) (st: state_p a m) (idx: index_t) =
| sub st (idx *. row_len a m) (row_len a m) | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.load_row | val load_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> ws:lbuffer (word_t a) 4ul ->
Stack unit
(requires (fun h -> live h r1 /\ live h ws /\ disjoint r1 ws))
(ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\
row_v h1 r1 == Spec.( load_row (as_seq h0 ws)))) | val load_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> ws:lbuffer (word_t a) 4ul ->
Stack unit
(requires (fun h -> live h r1 /\ live h ws /\ disjoint r1 ws))
(ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\
row_v h1 r1 == Spec.( load_row (as_seq h0 ws)))) | let load_row #a #m r ws = create_row r ws.(0ul) ws.(1ul) ws.(2ul) ws.(3ul) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 74,
"end_line": 250,
"start_col": 0,
"start_line": 250
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200"
noextract inline_for_extraction
let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1
#pop-options
#push-options "--z3rlimit 50"
noextract inline_for_extraction
let permr_row #a #m r1 n =
[@inline_let]
let n0 = n in
[@inline_let]
let n1 = (n+.1ul)%.4ul in
[@inline_let]
let n2 = (n+.2ul)%.4ul in
[@inline_let]
let n3 = (n+.3ul)%.4ul in
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
let v0 : vec_t U32 4 = r1.(0ul) in
let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| Spec.Blake2B,M256 ->
let v0 : vec_t U64 4 = r1.(0ul) in
let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| _ ->
let h0 = ST.get() in
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
let x0 = r1.(n0) in
let x1 = r1.(n1) in
let x2 = r1.(n2) in
let x3 = r1.(n3) in
r1.(0ul) <- x0;
r1.(1ul) <- x1;
r1.(2ul) <- x2;
r1.(3ul) <- x3;
let h1 = ST.get() in
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4])));
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4]))));
Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3));
()
#pop-options
#push-options "--z3rlimit 50"
let create4_lemma #a x0 x1 x2 x3 =
let open Lib.Sequence in
let l : list a = [x0;x1;x2;x3] in
assert_norm (List.Tot.length l = 4);
let s1 : lseq a 4 = of_list l in
let s2 : lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2
#pop-options
noextract inline_for_extraction
let alloc_row a m = create (row_len a m) (zero_element a m)
noextract inline_for_extraction
let create_row #a #m r w0 w1 w2 w3 =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128
| Spec.Blake2B,M256 ->
r.(0ul) <- vec_load4 w0 w1 w2 w3
| _ ->
r.(0ul) <- w0;
r.(1ul) <- w1;
r.(2ul) <- w2;
r.(3ul) <- w3;
let h1 = ST.get() in
Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r1: Hacl.Impl.Blake2.Core.row_p a m -> ws: Lib.Buffer.lbuffer (Hacl.Impl.Blake2.Core.word_t a) 4ul
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Hacl.Impl.Blake2.Core.row_p",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Blake2.Core.word_t",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Blake2.Core.create_row",
"Prims.unit",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT"
] | [] | false | true | false | false | false | let load_row #a #m r ws =
| create_row r ws.(0ul) ws.(1ul) ws.(2ul) ws.(3ul) | false |
Vale.Stdcalls.X64.Fadd.fsti | Vale.Stdcalls.X64.Fadd.b64 | val b64 : Type0 | let b64 = buf_t TUInt64 TUInt64 | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | module Vale.Stdcalls.X64.Fadd
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
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 FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
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.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fadd.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"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": "FStar.Mul",
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.Interop.Base.buf_t",
"Vale.Arch.HeapTypes_s.TUInt64"
] | [] | false | false | false | true | true | let b64 =
| buf_t TUInt64 TUInt64 | false |
|
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.state_v | val state_v: #a:Spec.alg -> #m:m_spec -> mem -> state_p a m -> GTot (Spec.state a) | val state_v: #a:Spec.alg -> #m:m_spec -> mem -> state_p a m -> GTot (Spec.state a) | let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3 | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 95,
"start_col": 0,
"start_line": 90
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> st: Hacl.Impl.Blake2.Core.state_p a m
-> Prims.GTot (Spec.Blake2.Definitions.state a) | Prims.GTot | [
"sometrivial"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Blake2.Core.state_p",
"Lib.Sequence.create4",
"Spec.Blake2.Definitions.row",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.SEC",
"Hacl.Impl.Blake2.Core.row_v",
"Hacl.Impl.Blake2.Core.g_rowi",
"FStar.UInt32.__uint_to_t",
"Spec.Blake2.Definitions.state"
] | [] | false | false | false | false | false | let state_v (#a: Spec.alg) (#m: m_spec) (h: mem) (st: state_p a m) : GTot (Spec.state a) =
| let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3 | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.alloc_row | val alloc_row: a:Spec.alg -> m:m_spec ->
StackInline (row_p a m)
(requires (fun h -> True))
(ensures (fun h0 r h1 -> stack_allocated r h0 h1 (Lib.Sequence.create (v (row_len a m)) (zero_element a m)) /\
live h1 r /\
row_v h1 r == Spec.zero_row a)) | val alloc_row: a:Spec.alg -> m:m_spec ->
StackInline (row_p a m)
(requires (fun h -> True))
(ensures (fun h0 r h1 -> stack_allocated r h0 h1 (Lib.Sequence.create (v (row_len a m)) (zero_element a m)) /\
live h1 r /\
row_v h1 r == Spec.zero_row a)) | let alloc_row a m = create (row_len a m) (zero_element a m) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 59,
"end_line": 232,
"start_col": 0,
"start_line": 232
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200"
noextract inline_for_extraction
let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1
#pop-options
#push-options "--z3rlimit 50"
noextract inline_for_extraction
let permr_row #a #m r1 n =
[@inline_let]
let n0 = n in
[@inline_let]
let n1 = (n+.1ul)%.4ul in
[@inline_let]
let n2 = (n+.2ul)%.4ul in
[@inline_let]
let n3 = (n+.3ul)%.4ul in
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
let v0 : vec_t U32 4 = r1.(0ul) in
let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| Spec.Blake2B,M256 ->
let v0 : vec_t U64 4 = r1.(0ul) in
let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| _ ->
let h0 = ST.get() in
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
let x0 = r1.(n0) in
let x1 = r1.(n1) in
let x2 = r1.(n2) in
let x3 = r1.(n3) in
r1.(0ul) <- x0;
r1.(1ul) <- x1;
r1.(2ul) <- x2;
r1.(3ul) <- x3;
let h1 = ST.get() in
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4])));
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4]))));
Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3));
()
#pop-options
#push-options "--z3rlimit 50"
let create4_lemma #a x0 x1 x2 x3 =
let open Lib.Sequence in
let l : list a = [x0;x1;x2;x3] in
assert_norm (List.Tot.length l = 4);
let s1 : lseq a 4 = of_list l in
let s2 : lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2
#pop-options | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec
-> FStar.HyperStack.ST.StackInline (Hacl.Impl.Blake2.Core.row_p a m) | FStar.HyperStack.ST.StackInline | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Lib.Buffer.create",
"Hacl.Impl.Blake2.Core.element_t",
"Hacl.Impl.Blake2.Core.row_len",
"Hacl.Impl.Blake2.Core.zero_element",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Blake2.Core.row_p"
] | [] | false | true | false | false | false | let alloc_row a m =
| create (row_len a m) (zero_element a m) | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.create_default_params | val create_default_params: a:Spec.alg ->
salt: lbuffer uint8 (salt_len a) ->
personal: lbuffer uint8 (personal_len a) ->
Stack (blake2_params a)
(requires fun h -> live h salt /\ live h personal /\
as_seq h salt == Seq.create (Spec.salt_length a) (u8 0) /\
as_seq h personal == Seq.create (Spec.personal_length a) (u8 0)
)
(ensures (fun h0 p h1 ->
h0 == h1 /\
blake2_params_loc p == loc salt `union` loc personal /\
blake2_params_inv h1 p /\
blake2_params_v h1 p == Spec.blake2_default_params a)) | val create_default_params: a:Spec.alg ->
salt: lbuffer uint8 (salt_len a) ->
personal: lbuffer uint8 (personal_len a) ->
Stack (blake2_params a)
(requires fun h -> live h salt /\ live h personal /\
as_seq h salt == Seq.create (Spec.salt_length a) (u8 0) /\
as_seq h personal == Seq.create (Spec.personal_length a) (u8 0)
)
(ensures (fun h0 p h1 ->
h0 == h1 /\
blake2_params_loc p == loc salt `union` loc personal /\
blake2_params_inv h1 p /\
blake2_params_v h1 p == Spec.blake2_default_params a)) | let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 57,
"start_col": 0,
"start_line": 34
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = () | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Blake2.Definitions.alg ->
salt: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Impl.Blake2.Core.salt_len a) ->
personal: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Impl.Blake2.Core.personal_len a)
-> FStar.HyperStack.ST.Stack (Hacl.Impl.Blake2.Core.blake2_params a) | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Impl.Blake2.Core.salt_len",
"Hacl.Impl.Blake2.Core.personal_len",
"Hacl.Impl.Blake2.Core.Mkblake2s_params",
"Lib.IntTypes.u8",
"Lib.IntTypes.u32",
"Lib.IntTypes.u16",
"Hacl.Impl.Blake2.Core.blake2s_params",
"Hacl.Impl.Blake2.Core.Mkblake2b_params",
"Hacl.Impl.Blake2.Core.blake2_params"
] | [] | false | true | false | false | false | let create_default_params a salt personal =
| match a with
| Spec.Blake2S ->
{
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = salt;
personal = personal
}
<:
blake2s_params
| Spec.Blake2B ->
{
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = salt;
personal = personal
} | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.gather_row | val gather_row: #a:Spec.alg -> #ms:m_spec -> r:row_p a ms -> m:block_w a ->
i0: Spec.sigma_elt_t -> i1:Spec.sigma_elt_t -> i2:Spec.sigma_elt_t -> i3:Spec.sigma_elt_t
-> Stack unit
(requires (fun h -> live h r /\ live h m /\ disjoint r m))
(ensures (fun h0 _ h1 -> modifies (loc r) h0 h1 /\
row_v h1 r == Spec.(gather_row (as_seq h0 m) i0 i1 i2 i3))) | val gather_row: #a:Spec.alg -> #ms:m_spec -> r:row_p a ms -> m:block_w a ->
i0: Spec.sigma_elt_t -> i1:Spec.sigma_elt_t -> i2:Spec.sigma_elt_t -> i3:Spec.sigma_elt_t
-> Stack unit
(requires (fun h -> live h r /\ live h m /\ disjoint r m))
(ensures (fun h0 _ h1 -> modifies (loc r) h0 h1 /\
row_v h1 r == Spec.(gather_row (as_seq h0 m) i0 i1 i2 i3))) | let gather_row #a #ms r m i0 i1 i2 i3 =
create_row r m.(i0) m.(i1) m.(i2) m.(i3) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 44,
"end_line": 282,
"start_col": 0,
"start_line": 281
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200"
noextract inline_for_extraction
let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1
#pop-options
#push-options "--z3rlimit 50"
noextract inline_for_extraction
let permr_row #a #m r1 n =
[@inline_let]
let n0 = n in
[@inline_let]
let n1 = (n+.1ul)%.4ul in
[@inline_let]
let n2 = (n+.2ul)%.4ul in
[@inline_let]
let n3 = (n+.3ul)%.4ul in
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
let v0 : vec_t U32 4 = r1.(0ul) in
let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| Spec.Blake2B,M256 ->
let v0 : vec_t U64 4 = r1.(0ul) in
let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| _ ->
let h0 = ST.get() in
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
let x0 = r1.(n0) in
let x1 = r1.(n1) in
let x2 = r1.(n2) in
let x3 = r1.(n3) in
r1.(0ul) <- x0;
r1.(1ul) <- x1;
r1.(2ul) <- x2;
r1.(3ul) <- x3;
let h1 = ST.get() in
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4])));
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4]))));
Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3));
()
#pop-options
#push-options "--z3rlimit 50"
let create4_lemma #a x0 x1 x2 x3 =
let open Lib.Sequence in
let l : list a = [x0;x1;x2;x3] in
assert_norm (List.Tot.length l = 4);
let s1 : lseq a 4 = of_list l in
let s2 : lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2
#pop-options
noextract inline_for_extraction
let alloc_row a m = create (row_len a m) (zero_element a m)
noextract inline_for_extraction
let create_row #a #m r w0 w1 w2 w3 =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128
| Spec.Blake2B,M256 ->
r.(0ul) <- vec_load4 w0 w1 w2 w3
| _ ->
r.(0ul) <- w0;
r.(1ul) <- w1;
r.(2ul) <- w2;
r.(3ul) <- w3;
let h1 = ST.get() in
Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3)
noextract inline_for_extraction
let load_row #a #m r ws = create_row r ws.(0ul) ws.(1ul) ws.(2ul) ws.(3ul)
noextract inline_for_extraction
let store_row #a #m b r =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
vec_store_le #U32 #4 b r.(0ul)
| Spec.Blake2B,M256 ->
vec_store_le #U64 #4 b r.(0ul)
| _ ->
uints_to_bytes_le #(Spec.wt a) 4ul b r
noextract inline_for_extraction
let store_row32 #a #m b r =
push_frame();
let h0 = ST.get() in
let b8 = create (size_row a) (u8 0) in
store_row b8 r;
let h1 = ST.get() in
uints_from_bytes_le b b8;
let h2 = ST.get() in
assert (as_seq h1 b8 == Lib.ByteSequence.uints_to_bytes_le #(Spec.wt a) (row_v h0 r));
assert (as_seq h2 b == Lib.ByteSequence.uints_from_bytes_le #(Spec.wt a) (as_seq h1 b8));
Lib.Sequence.eq_intro (as_seq h2 b) (Spec.load_row (as_seq h2 b));
assert (Spec.load_row (as_seq h2 b) ==
Lib.ByteSequence.uints_from_bytes_le (as_seq h1 b8));
Lib.ByteSequence.lemma_uints_to_from_bytes_le_preserves_value (row_v h0 r);
pop_frame() | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: Hacl.Impl.Blake2.Core.row_p a ms ->
m: Hacl.Impl.Blake2.Core.block_w a ->
i0: Spec.Blake2.Definitions.sigma_elt_t ->
i1: Spec.Blake2.Definitions.sigma_elt_t ->
i2: Spec.Blake2.Definitions.sigma_elt_t ->
i3: Spec.Blake2.Definitions.sigma_elt_t
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Hacl.Impl.Blake2.Core.row_p",
"Hacl.Impl.Blake2.Core.block_w",
"Spec.Blake2.Definitions.sigma_elt_t",
"Hacl.Impl.Blake2.Core.create_row",
"Prims.unit",
"Hacl.Impl.Blake2.Core.word_t",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT",
"FStar.UInt32.__uint_to_t"
] | [] | false | true | false | false | false | let gather_row #a #ms r m i0 i1 i2 i3 =
| create_row r m.(i0) m.(i1) m.(i2) m.(i3) | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.xor_row | val xor_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m ->
Stack unit
(requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2))
(ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\
row_v h1 r1 == Spec.( row_v h0 r1 ^| row_v h0 r2 ))) | val xor_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m ->
Stack unit
(requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2))
(ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\
row_v h1 r1 == Spec.( row_v h0 r1 ^| row_v h0 r2 ))) | let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2 | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 147,
"start_col": 0,
"start_line": 139
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r1: Hacl.Impl.Blake2.Core.row_p a m -> r2: Hacl.Impl.Blake2.Core.row_p a m
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Hacl.Impl.Blake2.Core.row_p",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Blake2.Core.element_t",
"Hacl.Impl.Blake2.Core.row_len",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Lib.IntVector.vec_xor",
"Lib.IntTypes.U32",
"Lib.IntVector.vec_t",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT",
"Lib.IntTypes.U64",
"FStar.Pervasives.Native.tuple2",
"Lib.Buffer.map2T",
"Lib.IntTypes.logxor",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.SEC"
] | [] | false | true | false | false | false | let xor_row #a #m r1 r2 =
| match a, m with
| Spec.Blake2S, M128 -> r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S, M256 -> r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B, M256 -> r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2 | false |
Vale.Stdcalls.X64.Fadd.fsti | Vale.Stdcalls.X64.Fadd.code_add1 | val code_add1 : Vale.X64.Decls.va_code | let code_add1 = FU.va_code_Fast_add1_stdcall IA.win | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 112,
"start_col": 0,
"start_line": 112
} | module Vale.Stdcalls.X64.Fadd
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
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 FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
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 b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let add1_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FU.va_req_Fast_add1_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__] noextract
let add1_post : VSig.vale_post dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#reset-options "--z3rlimit 50"
[@__reduce__] noextract
let add1_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
add1_pre code out f1 f2 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 /\
add1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1);
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
noextract
let add1_lemma = as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma' | {
"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.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fadd.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"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": "FStar.Mul",
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.X64.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.Curve25519.X64.FastUtil.va_code_Fast_add1_stdcall",
"Vale.Interop.Assumptions.win"
] | [] | false | false | false | true | false | let code_add1 =
| FU.va_code_Fast_add1_stdcall IA.win | false |
|
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.g_rowi_unchanged | val g_rowi_unchanged: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t ->
Lemma (requires (as_seq h0 st == as_seq h1 st))
(ensures (as_seq h0 (g_rowi st i) == as_seq h1 (g_rowi st i)))
[SMTPat (as_seq h0 (g_rowi st i)); SMTPat (as_seq h1 (g_rowi st i))] | val g_rowi_unchanged: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st:state_p a m -> i:index_t ->
Lemma (requires (as_seq h0 st == as_seq h1 st))
(ensures (as_seq h0 (g_rowi st i) == as_seq h1 (g_rowi st i)))
[SMTPat (as_seq h0 (g_rowi st i)); SMTPat (as_seq h1 (g_rowi st i))] | let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m)) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 81,
"start_col": 0,
"start_line": 76
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else () | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_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 |
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
st: Hacl.Impl.Blake2.Core.state_p a m ->
i: Hacl.Impl.Blake2.Core.index_t
-> FStar.Pervasives.Lemma (requires Lib.Buffer.as_seq h0 st == Lib.Buffer.as_seq h1 st)
(ensures
Lib.Buffer.as_seq h0 (Hacl.Impl.Blake2.Core.g_rowi st i) ==
Lib.Buffer.as_seq h1 (Hacl.Impl.Blake2.Core.g_rowi st i))
[
SMTPat (Lib.Buffer.as_seq h0 (Hacl.Impl.Blake2.Core.g_rowi st i));
SMTPat (Lib.Buffer.as_seq h1 (Hacl.Impl.Blake2.Core.g_rowi st i))
] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Blake2.Core.state_p",
"Hacl.Impl.Blake2.Core.index_t",
"LowStar.Monotonic.Buffer.as_seq_gsub",
"Hacl.Impl.Blake2.Core.element_t",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Blake2.Core.row_len",
"Prims.unit",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.Buffer.length",
"Lib.Buffer.MUT"
] | [] | true | false | true | false | false | let g_rowi_unchanged #a #m h0 h1 st i =
| assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_
#(LowStar.Buffer.trivial_preorder (element_t a m))
#(LowStar.Buffer.trivial_preorder (element_t a m))
h0
st
(i *. row_len a m)
(row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_
#(LowStar.Buffer.trivial_preorder (element_t a m))
#(LowStar.Buffer.trivial_preorder (element_t a m))
h1
st
(i *. row_len a m)
(row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m)) | false |
Vale.Stdcalls.X64.Fadd.fsti | Vale.Stdcalls.X64.Fadd.fadd_pre | val fadd_pre:VSig.vale_pre fadd_dom | val fadd_pre:VSig.vale_pre fadd_dom | let fadd_pre : VSig.vale_pre fadd_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state) ->
FH.va_req_Fadd_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 141,
"start_col": 0,
"start_line": 134
} | module Vale.Stdcalls.X64.Fadd
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
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 FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
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 b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let add1_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FU.va_req_Fast_add1_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__] noextract
let add1_post : VSig.vale_post dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#reset-options "--z3rlimit 50"
[@__reduce__] noextract
let add1_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
add1_pre code out f1 f2 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 /\
add1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1);
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
noextract
let add1_lemma = as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma'
noextract
let code_add1 = FU.va_code_Fast_add1_stdcall IA.win
(* Here's the type expected for the add1 wrapper *)
[@__reduce__] noextract
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_add1
dom
[]
_
_
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
[@__reduce__] noextract
let fadd_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_no_mod] in
assert_norm (List.length y = 3);
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.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fadd.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"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": "FStar.Mul",
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.Fadd.fadd_dom | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.Fadd.b64",
"Vale.X64.Decls.va_state",
"Vale.Curve25519.X64.FastHybrid.va_req_Fadd_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt64",
"Prims.prop"
] | [] | false | false | false | true | false | let fadd_pre:VSig.vale_pre fadd_dom =
| fun (c: V.va_code) (out: b64) (f1: b64) (f2: b64) (va_s0: V.va_state) ->
FH.va_req_Fadd_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.g_rowi_disjoint | val g_rowi_disjoint: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx1:index_t -> idx2:index_t ->
Lemma (ensures (v idx1 <> v idx2 ==> disjoint (g_rowi st idx1) (g_rowi st idx2)))
[SMTPat (disjoint (g_rowi st idx1) (g_rowi st idx2))] | val g_rowi_disjoint: #a:Spec.alg -> #m:m_spec -> st:state_p a m -> idx1:index_t -> idx2:index_t ->
Lemma (ensures (v idx1 <> v idx2 ==> disjoint (g_rowi st idx1) (g_rowi st idx2)))
[SMTPat (disjoint (g_rowi st idx1) (g_rowi st idx2))] | let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else () | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 9,
"end_line": 74,
"start_col": 0,
"start_line": 60
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_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.Blake2.Core.state_p a m ->
idx1: Hacl.Impl.Blake2.Core.index_t ->
idx2: Hacl.Impl.Blake2.Core.index_t
-> FStar.Pervasives.Lemma
(ensures
Lib.IntTypes.v idx1 <> Lib.IntTypes.v idx2 ==>
Lib.Buffer.disjoint (Hacl.Impl.Blake2.Core.g_rowi st idx1)
(Hacl.Impl.Blake2.Core.g_rowi st idx2))
[
SMTPat (Lib.Buffer.disjoint (Hacl.Impl.Blake2.Core.g_rowi st idx1)
(Hacl.Impl.Blake2.Core.g_rowi st idx2))
] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Hacl.Impl.Blake2.Core.state_p",
"Hacl.Impl.Blake2.Core.index_t",
"Lib.IntTypes.op_Less_Dot",
"Lib.IntTypes.U32",
"LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer",
"Hacl.Impl.Blake2.Core.element_t",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.op_Star_Dot",
"Lib.IntTypes.PUB",
"Hacl.Impl.Blake2.Core.row_len",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Hacl.Impl.Blake2.Core.g_rowi",
"Lib.Buffer.gsub",
"FStar.UInt32.__uint_to_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Prims.bool"
] | [] | false | false | true | false | false | let g_rowi_disjoint #a #m st idx1 idx2 =
| if idx1 <. idx2
then
(assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 == gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 == gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_
#((LowStar.Buffer.trivial_preorder (element_t a m)))
#((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m)))
else
if idx2 <. idx1
then
(assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 == gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_
#((LowStar.Buffer.trivial_preorder (element_t a m)))
#((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))) | false |
CQueue.LList.fsti | CQueue.LList.cllist_lvalue | val cllist_lvalue : a: Type0 -> Type0 | let cllist_lvalue (a: Type0) = (c: cllist_ptrvalue a { cllist_ptrvalue_is_null c == false }) | {
"file_name": "share/steel/examples/steel/CQueue.LList.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 92,
"end_line": 24,
"start_col": 0,
"start_line": 24
} | module CQueue.LList
include CQueue.Cell
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.FractionalPermission
open Steel.Reference
(* A C lvalue view of a llist struct, as a pair of two references for its head and tail fields (C language aspects only, no semantic content)
See CQueue.c: cllist_*
*)
val cllist_ptrvalue (a: Type0) : Tot Type0 (* "cllist *" seen as a rvalue *)
val cllist_ptrvalue_null (a: Type0) : Tot (cllist_ptrvalue a)
(* Pointer arithmetic: comparison to null, and pointer to fields. TODO: split these operations between Ghost and Steel, with a proper model of a "permission to do pointer arithmetic without actually reading the value/dereferencing" *)
val cllist_ptrvalue_is_null (#a: Type0) (c: cllist_ptrvalue a) : Pure bool
(requires True)
(ensures (fun b -> b == true <==> c == cllist_ptrvalue_null a)) | {
"checked_file": "/",
"dependencies": [
"Steel.Reference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.Cell.fsti.checked"
],
"interface_file": false,
"source_file": "CQueue.LList.fsti"
} | [
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue.Cell",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue",
"short_module": null
},
{
"abbrev": 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 -> Type0 | Prims.Tot | [
"total"
] | [] | [
"CQueue.LList.cllist_ptrvalue",
"Prims.eq2",
"Prims.bool",
"CQueue.LList.cllist_ptrvalue_is_null"
] | [] | false | false | false | true | true | let cllist_lvalue (a: Type0) =
| (c: cllist_ptrvalue a {cllist_ptrvalue_is_null c == false}) | false |
|
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.ror_row | val ror_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:rotval (Spec.wt a) ->
Stack unit
(requires (fun h -> live h r1))
(ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\
row_v h1 r1 == Spec.( row_v h0 r1 >>>| r2 ))) | val ror_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:rotval (Spec.wt a) ->
Stack unit
(requires (fun h -> live h r1))
(ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\
row_v h1 r1 == Spec.( row_v h0 r1 >>>| r2 ))) | let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1 | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 174,
"start_col": 0,
"start_line": 164
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200" | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_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 | r1: Hacl.Impl.Blake2.Core.row_p a m -> r2: Lib.IntTypes.rotval (Spec.Blake2.Definitions.wt a)
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Hacl.Impl.Blake2.Core.row_p",
"Lib.IntTypes.rotval",
"Spec.Blake2.Definitions.wt",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Blake2.Core.element_t",
"Hacl.Impl.Blake2.Core.row_len",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Lib.IntVector.vec_rotate_right",
"Lib.IntTypes.U32",
"Lib.IntVector.vec_t",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT",
"Lib.IntTypes.U64",
"FStar.Pervasives.Native.tuple2",
"Lib.Buffer.mapT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.rotate_right_i",
"Lib.Buffer.lbuffer_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t"
] | [] | false | true | false | false | false | let ror_row #a #m r1 r2 =
| match a, m with
| Spec.Blake2S, M128 -> r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S, M256 -> r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B, M256 -> r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1 | false |
CQueue.LList.fsti | CQueue.LList.cllist' | val cllist' (#a: Type0) (c: cllist_ptrvalue a) : GTot vprop' | val cllist' (#a: Type0) (c: cllist_ptrvalue a) : GTot vprop' | let cllist'
(#a: Type0)
(c: cllist_ptrvalue a)
: GTot vprop'
= {
hp = cllist_hp c;
t = vllist a;
sel = cllist_sel c;
} | {
"file_name": "share/steel/examples/steel/CQueue.LList.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 1,
"end_line": 63,
"start_col": 0,
"start_line": 55
} | module CQueue.LList
include CQueue.Cell
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.FractionalPermission
open Steel.Reference
(* A C lvalue view of a llist struct, as a pair of two references for its head and tail fields (C language aspects only, no semantic content)
See CQueue.c: cllist_*
*)
val cllist_ptrvalue (a: Type0) : Tot Type0 (* "cllist *" seen as a rvalue *)
val cllist_ptrvalue_null (a: Type0) : Tot (cllist_ptrvalue a)
(* Pointer arithmetic: comparison to null, and pointer to fields. TODO: split these operations between Ghost and Steel, with a proper model of a "permission to do pointer arithmetic without actually reading the value/dereferencing" *)
val cllist_ptrvalue_is_null (#a: Type0) (c: cllist_ptrvalue a) : Pure bool
(requires True)
(ensures (fun b -> b == true <==> c == cllist_ptrvalue_null a))
let cllist_lvalue (a: Type0) = (c: cllist_ptrvalue a { cllist_ptrvalue_is_null c == false }) (* "cllist" seen as a lvalue, or "cllist * const". IMPORTANT: one MUST NOT use "ref cllist_lvalue" in C code. In other words, ref can be used to model pointers to rvalues only. *)
val cllist_head (#a: Type0) (c: cllist_lvalue a) : Pure (ref (ccell_ptrvalue a))
(requires True)
(ensures (fun v -> ~ (is_null v)))
val cllist_tail (#a: Type0) (c: cllist_lvalue a) : Pure (ref (ref (ccell_ptrvalue a)))
(requires True)
(ensures (fun v -> ~ (is_null v)))
(* Important: we DO NOT provide a pure constructor for this data type, since its fields MUST be allocated at the same time and a cell MUST NOT be forged from references that would not come from such same-time allocation. *)
(* The "high-level" value of a llist (should NEVER be used in C code, only in specs) *)
noeq
type vllist (a: Type0) = {
vllist_head : ccell_ptrvalue a;
vllist_tail : ref (ccell_ptrvalue a);
}
val cllist_hp
(#a: Type0)
(c: cllist_ptrvalue a)
: Tot (slprop u#1)
val cllist_sel
(#a: Type0)
(c: cllist_ptrvalue a)
: GTot (selector (vllist a) (cllist_hp c)) | {
"checked_file": "/",
"dependencies": [
"Steel.Reference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.Cell.fsti.checked"
],
"interface_file": false,
"source_file": "CQueue.LList.fsti"
} | [
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue.Cell",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue",
"short_module": null
},
{
"abbrev": 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 | c: CQueue.LList.cllist_ptrvalue a -> Prims.GTot Steel.Effect.Common.vprop' | Prims.GTot | [
"sometrivial"
] | [] | [
"CQueue.LList.cllist_ptrvalue",
"Steel.Effect.Common.Mkvprop'",
"CQueue.LList.cllist_hp",
"CQueue.LList.vllist",
"CQueue.LList.cllist_sel",
"Steel.Effect.Common.vprop'"
] | [] | false | false | false | false | false | let cllist' (#a: Type0) (c: cllist_ptrvalue a) : GTot vprop' =
| { hp = cllist_hp c; t = vllist a; sel = cllist_sel c } | false |
Vale.Stdcalls.X64.Fadd.fsti | Vale.Stdcalls.X64.Fadd.code_Fadd | val code_Fadd : Vale.X64.Decls.va_code | let code_Fadd = FH.va_code_Fadd_stdcall IA.win | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 191,
"start_col": 0,
"start_line": 191
} | module Vale.Stdcalls.X64.Fadd
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
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 FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
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 b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let add1_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FU.va_req_Fast_add1_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__] noextract
let add1_post : VSig.vale_post dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#reset-options "--z3rlimit 50"
[@__reduce__] noextract
let add1_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
add1_pre code out f1 f2 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 /\
add1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1);
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
noextract
let add1_lemma = as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma'
noextract
let code_add1 = FU.va_code_Fast_add1_stdcall IA.win
(* Here's the type expected for the add1 wrapper *)
[@__reduce__] noextract
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_add1
dom
[]
_
_
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
[@__reduce__] noextract
let fadd_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_no_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fadd_pre : VSig.vale_pre fadd_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state) ->
FH.va_req_Fadd_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2)
[@__reduce__] noextract
let fadd_post : VSig.vale_post fadd_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FH.va_ens_Fadd_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 100"
[@__reduce__] noextract
let fadd_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fadd_pre code out f1 f2 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 /\
fadd_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FH.va_lemma_Fadd_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
noextract
let fadd_lemma = as_t #(VSig.vale_sig_stdcall fadd_pre fadd_post) fadd_lemma' | {
"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.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fadd.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"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": "FStar.Mul",
"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.Curve25519.X64.FastHybrid.va_code_Fadd_stdcall",
"Vale.Interop.Assumptions.win"
] | [] | false | false | false | true | false | let code_Fadd =
| FH.va_code_Fadd_stdcall IA.win | false |
|
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.add_row | val add_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m ->
Stack unit
(requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2))
(ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\
row_v h1 r1 == Spec.( row_v h0 r1 +| row_v h0 r2 ))) | val add_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> r2:row_p a m ->
Stack unit
(requires (fun h -> live h r1 /\ live h r2 /\ disjoint r1 r2))
(ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\
row_v h1 r1 == Spec.( row_v h0 r1 +| row_v h0 r2 ))) | let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2 | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 159,
"start_col": 0,
"start_line": 151
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2 | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r1: Hacl.Impl.Blake2.Core.row_p a m -> r2: Hacl.Impl.Blake2.Core.row_p a m
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Hacl.Impl.Blake2.Core.row_p",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Blake2.Core.element_t",
"Hacl.Impl.Blake2.Core.row_len",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Lib.IntVector.vec_add_mod",
"Lib.IntTypes.U32",
"Lib.IntVector.vec_t",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT",
"Lib.IntTypes.U64",
"FStar.Pervasives.Native.tuple2",
"Lib.Buffer.map2T",
"Lib.IntTypes.add_mod",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.SEC"
] | [] | false | true | false | false | false | let add_row #a #m r1 r2 =
| match a, m with
| Spec.Blake2S, M128 -> r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S, M256 -> r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B, M256 -> r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2 | false |
Vale.Stdcalls.X64.Fadd.fsti | Vale.Stdcalls.X64.Fadd.fadd_post | val fadd_post:VSig.vale_post fadd_dom | val fadd_post:VSig.vale_post fadd_dom | let fadd_post : VSig.vale_post fadd_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FH.va_ens_Fadd_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.Fadd.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 112,
"end_line": 152,
"start_col": 0,
"start_line": 144
} | module Vale.Stdcalls.X64.Fadd
val z3rlimit_hack (x:nat) : squash (x < x + x + 1)
#reset-options "--z3rlimit 50"
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 FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
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 b64 = buf_t TUInt64 TUInt64
[@__reduce__] noextract
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__] noextract
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let add1_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FU.va_req_Fast_add1_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__] noextract
let add1_post : VSig.vale_post dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Fast_add1_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#reset-options "--z3rlimit 50"
[@__reduce__] noextract
let add1_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
add1_pre code out f1 f2 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 /\
add1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Fast_add1_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
assert (VSig.vale_calling_conventions_stdcall va_s0 va_s1);
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
noextract
let add1_lemma = as_t #(VSig.vale_sig_stdcall add1_pre add1_post) add1_lemma'
noextract
let code_add1 = FU.va_code_Fast_add1_stdcall IA.win
(* Here's the type expected for the add1 wrapper *)
[@__reduce__] noextract
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 4);
IX64.as_lowstar_sig_t_weak_stdcall
code_add1
dom
[]
_
_
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
[@__reduce__] noextract
let fadd_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_no_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let fadd_pre : VSig.vale_pre fadd_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state) ->
FH.va_req_Fadd_stdcall c va_s0 IA.win
(as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) | {
"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.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.Fadd.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"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": "FStar.Mul",
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.Fadd.fadd_dom | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.Fadd.b64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Vale.Curve25519.X64.FastHybrid.va_ens_Fadd_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt64",
"Prims.prop"
] | [] | false | false | false | true | false | let fadd_post:VSig.vale_post fadd_dom =
| fun
(c: V.va_code)
(out: b64)
(f1: b64)
(f2: b64)
(va_s0: V.va_state)
(va_s1: V.va_state)
(f: V.va_fuel)
->
FH.va_ens_Fadd_stdcall c
va_s0
IA.win
(as_vale_buffer out)
(as_vale_buffer f1)
(as_vale_buffer f2)
va_s1
f | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.create4_lemma | val create4_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a ->
Lemma (ensures (
let l = [ x0; x1; x2; x3 ] in
assert_norm (List.Tot.length l = 4);
Lib.Sequence.createL l == Lib.Sequence.create4 x0 x1 x2 x3))
[SMTPat (Lib.Sequence.createL [x0;x1;x2;x3])] | val create4_lemma: #a:Type -> x0:a -> x1:a -> x2:a -> x3:a ->
Lemma (ensures (
let l = [ x0; x1; x2; x3 ] in
assert_norm (List.Tot.length l = 4);
Lib.Sequence.createL l == Lib.Sequence.create4 x0 x1 x2 x3))
[SMTPat (Lib.Sequence.createL [x0;x1;x2;x3])] | let create4_lemma #a x0 x1 x2 x3 =
let open Lib.Sequence in
let l : list a = [x0;x1;x2;x3] in
assert_norm (List.Tot.length l = 4);
let s1 : lseq a 4 = of_list l in
let s2 : lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2 | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 228,
"start_col": 0,
"start_line": 221
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200"
noextract inline_for_extraction
let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1
#pop-options
#push-options "--z3rlimit 50"
noextract inline_for_extraction
let permr_row #a #m r1 n =
[@inline_let]
let n0 = n in
[@inline_let]
let n1 = (n+.1ul)%.4ul in
[@inline_let]
let n2 = (n+.2ul)%.4ul in
[@inline_let]
let n3 = (n+.3ul)%.4ul in
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
let v0 : vec_t U32 4 = r1.(0ul) in
let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| Spec.Blake2B,M256 ->
let v0 : vec_t U64 4 = r1.(0ul) in
let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| _ ->
let h0 = ST.get() in
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
let x0 = r1.(n0) in
let x1 = r1.(n1) in
let x2 = r1.(n2) in
let x3 = r1.(n3) in
r1.(0ul) <- x0;
r1.(1ul) <- x1;
r1.(2ul) <- x2;
r1.(3ul) <- x3;
let h1 = ST.get() in
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4])));
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4]))));
Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3));
()
#pop-options | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_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 | x0: a -> x1: a -> x2: a -> x3: a
-> FStar.Pervasives.Lemma
(ensures
(let l = [x0; x1; x2; x3] in
FStar.Pervasives.assert_norm (FStar.List.Tot.Base.length l = 4);
Lib.Sequence.createL l == Lib.Sequence.create4 x0 x1 x2 x3))
[SMTPat (Lib.Sequence.createL [x0; x1; x2; x3])] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Lib.Sequence.eq_intro",
"Prims.unit",
"FStar.Seq.Properties.intro_of_list",
"Lib.Sequence.lseq",
"Lib.Sequence.create4",
"Lib.Sequence.of_list",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"Prims.Cons",
"Prims.Nil"
] | [] | true | false | true | false | false | let create4_lemma #a x0 x1 x2 x3 =
| let open Lib.Sequence in
let l:list a = [x0; x1; x2; x3] in
assert_norm (List.Tot.length l = 4);
let s1:lseq a 4 = of_list l in
let s2:lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2 | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.le_sigh | val le_sigh (a:Spec.alg) (m:m_spec): x:size_t { x == 4ul *. row_len a m } | val le_sigh (a:Spec.alg) (m:m_spec): x:size_t { x == 4ul *. row_len a m } | let le_sigh (a:Spec.alg) (m:m_spec): x:size_t { x == 4ul *. row_len a m } =
let open FStar.Mul in
assert_norm ((4 * 1) % pow2 32 = 4);
assert_norm ((4 * 4) % pow2 32 = 16);
Lib.IntTypes.mul_mod_lemma 4ul 1ul;
Lib.IntTypes.mul_mod_lemma 4ul 4ul;
match a,m with
| Spec.Blake2S,M128 -> 4ul
| Spec.Blake2S,M256 -> 4ul
| Spec.Blake2B,M256 -> 4ul
| _ -> 16ul | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 295,
"start_col": 0,
"start_line": 285
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200"
noextract inline_for_extraction
let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1
#pop-options
#push-options "--z3rlimit 50"
noextract inline_for_extraction
let permr_row #a #m r1 n =
[@inline_let]
let n0 = n in
[@inline_let]
let n1 = (n+.1ul)%.4ul in
[@inline_let]
let n2 = (n+.2ul)%.4ul in
[@inline_let]
let n3 = (n+.3ul)%.4ul in
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
let v0 : vec_t U32 4 = r1.(0ul) in
let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| Spec.Blake2B,M256 ->
let v0 : vec_t U64 4 = r1.(0ul) in
let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| _ ->
let h0 = ST.get() in
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
let x0 = r1.(n0) in
let x1 = r1.(n1) in
let x2 = r1.(n2) in
let x3 = r1.(n3) in
r1.(0ul) <- x0;
r1.(1ul) <- x1;
r1.(2ul) <- x2;
r1.(3ul) <- x3;
let h1 = ST.get() in
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4])));
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4]))));
Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3));
()
#pop-options
#push-options "--z3rlimit 50"
let create4_lemma #a x0 x1 x2 x3 =
let open Lib.Sequence in
let l : list a = [x0;x1;x2;x3] in
assert_norm (List.Tot.length l = 4);
let s1 : lseq a 4 = of_list l in
let s2 : lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2
#pop-options
noextract inline_for_extraction
let alloc_row a m = create (row_len a m) (zero_element a m)
noextract inline_for_extraction
let create_row #a #m r w0 w1 w2 w3 =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128
| Spec.Blake2B,M256 ->
r.(0ul) <- vec_load4 w0 w1 w2 w3
| _ ->
r.(0ul) <- w0;
r.(1ul) <- w1;
r.(2ul) <- w2;
r.(3ul) <- w3;
let h1 = ST.get() in
Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3)
noextract inline_for_extraction
let load_row #a #m r ws = create_row r ws.(0ul) ws.(1ul) ws.(2ul) ws.(3ul)
noextract inline_for_extraction
let store_row #a #m b r =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
vec_store_le #U32 #4 b r.(0ul)
| Spec.Blake2B,M256 ->
vec_store_le #U64 #4 b r.(0ul)
| _ ->
uints_to_bytes_le #(Spec.wt a) 4ul b r
noextract inline_for_extraction
let store_row32 #a #m b r =
push_frame();
let h0 = ST.get() in
let b8 = create (size_row a) (u8 0) in
store_row b8 r;
let h1 = ST.get() in
uints_from_bytes_le b b8;
let h2 = ST.get() in
assert (as_seq h1 b8 == Lib.ByteSequence.uints_to_bytes_le #(Spec.wt a) (row_v h0 r));
assert (as_seq h2 b == Lib.ByteSequence.uints_from_bytes_le #(Spec.wt a) (as_seq h1 b8));
Lib.Sequence.eq_intro (as_seq h2 b) (Spec.load_row (as_seq h2 b));
assert (Spec.load_row (as_seq h2 b) ==
Lib.ByteSequence.uints_from_bytes_le (as_seq h1 b8));
Lib.ByteSequence.lemma_uints_to_from_bytes_le_preserves_value (row_v h0 r);
pop_frame()
noextract inline_for_extraction
let gather_row #a #ms r m i0 i1 i2 i3 =
create_row r m.(i0) m.(i1) m.(i2) m.(i3) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec
-> x: Lib.IntTypes.size_t{x == 4ul *. Hacl.Impl.Blake2.Core.row_len a m} | Prims.Tot | [
"total"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"FStar.Pervasives.Native.Mktuple2",
"FStar.UInt32.__uint_to_t",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.size_t",
"Prims.eq2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.op_Star_Dot",
"Hacl.Impl.Blake2.Core.row_len",
"Prims.unit",
"Lib.IntTypes.mul_mod_lemma",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Prims.pow2"
] | [] | false | false | false | false | false | let le_sigh (a: Spec.alg) (m: m_spec) : x: size_t{x == 4ul *. row_len a m} =
| let open FStar.Mul in
assert_norm ((4 * 1) % pow2 32 = 4);
assert_norm ((4 * 4) % pow2 32 = 16);
Lib.IntTypes.mul_mod_lemma 4ul 1ul;
Lib.IntTypes.mul_mod_lemma 4ul 4ul;
match a, m with
| Spec.Blake2S, M128 -> 4ul
| Spec.Blake2S, M256 -> 4ul
| Spec.Blake2B, M256 -> 4ul
| _ -> 16ul | false |
CQueue.LList.fsti | CQueue.LList.cllist | val cllist (#a: Type0) (c: cllist_ptrvalue a) : Tot vprop | val cllist (#a: Type0) (c: cllist_ptrvalue a) : Tot vprop | let cllist (#a: Type0) (c: cllist_ptrvalue a) : Tot vprop =
VUnit (cllist' c) | {
"file_name": "share/steel/examples/steel/CQueue.LList.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 19,
"end_line": 67,
"start_col": 0,
"start_line": 66
} | module CQueue.LList
include CQueue.Cell
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.FractionalPermission
open Steel.Reference
(* A C lvalue view of a llist struct, as a pair of two references for its head and tail fields (C language aspects only, no semantic content)
See CQueue.c: cllist_*
*)
val cllist_ptrvalue (a: Type0) : Tot Type0 (* "cllist *" seen as a rvalue *)
val cllist_ptrvalue_null (a: Type0) : Tot (cllist_ptrvalue a)
(* Pointer arithmetic: comparison to null, and pointer to fields. TODO: split these operations between Ghost and Steel, with a proper model of a "permission to do pointer arithmetic without actually reading the value/dereferencing" *)
val cllist_ptrvalue_is_null (#a: Type0) (c: cllist_ptrvalue a) : Pure bool
(requires True)
(ensures (fun b -> b == true <==> c == cllist_ptrvalue_null a))
let cllist_lvalue (a: Type0) = (c: cllist_ptrvalue a { cllist_ptrvalue_is_null c == false }) (* "cllist" seen as a lvalue, or "cllist * const". IMPORTANT: one MUST NOT use "ref cllist_lvalue" in C code. In other words, ref can be used to model pointers to rvalues only. *)
val cllist_head (#a: Type0) (c: cllist_lvalue a) : Pure (ref (ccell_ptrvalue a))
(requires True)
(ensures (fun v -> ~ (is_null v)))
val cllist_tail (#a: Type0) (c: cllist_lvalue a) : Pure (ref (ref (ccell_ptrvalue a)))
(requires True)
(ensures (fun v -> ~ (is_null v)))
(* Important: we DO NOT provide a pure constructor for this data type, since its fields MUST be allocated at the same time and a cell MUST NOT be forged from references that would not come from such same-time allocation. *)
(* The "high-level" value of a llist (should NEVER be used in C code, only in specs) *)
noeq
type vllist (a: Type0) = {
vllist_head : ccell_ptrvalue a;
vllist_tail : ref (ccell_ptrvalue a);
}
val cllist_hp
(#a: Type0)
(c: cllist_ptrvalue a)
: Tot (slprop u#1)
val cllist_sel
(#a: Type0)
(c: cllist_ptrvalue a)
: GTot (selector (vllist a) (cllist_hp c))
[@__steel_reduce__]
let cllist'
(#a: Type0)
(c: cllist_ptrvalue a)
: GTot vprop'
= {
hp = cllist_hp c;
t = vllist a;
sel = cllist_sel c;
} | {
"checked_file": "/",
"dependencies": [
"Steel.Reference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"CQueue.Cell.fsti.checked"
],
"interface_file": false,
"source_file": "CQueue.LList.fsti"
} | [
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue.Cell",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue",
"short_module": null
},
{
"abbrev": 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 | c: CQueue.LList.cllist_ptrvalue a -> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"CQueue.LList.cllist_ptrvalue",
"Steel.Effect.Common.VUnit",
"CQueue.LList.cllist'",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | true | false | let cllist (#a: Type0) (c: cllist_ptrvalue a) : Tot vprop =
| VUnit (cllist' c) | false |
Vale.SHA.PPC64LE.SHA_helpers.fst | Vale.SHA.PPC64LE.SHA_helpers.lemma_be_to_n_4 | val lemma_be_to_n_4 (s: seq4 nat8)
: Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) ==
be_bytes_to_nat32 s) | val lemma_be_to_n_4 (s: seq4 nat8)
: Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) ==
be_bytes_to_nat32 s) | let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
} | {
"file_name": "vale/code/crypto/sha/Vale.SHA.PPC64LE.SHA_helpers.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 184,
"start_col": 0,
"start_line": 156
} | module Vale.SHA.PPC64LE.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
open Vale.Arch.TypesNative
open Vale.Def.Sel
open Vale.SHA2.Wrapper
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.SHA2.Wrapper
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
update_multi_opaque_aux SHA2_256 hash () blocks
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
assert_norm (List.length l == 8);
let hash = seq_of_list l in
assert (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
friend Lib.ByteSequence | {
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fst.checked",
"Vale.SHA2.Wrapper.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Sel.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.PPC64LE.SHA_helpers.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Sel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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",
"smt.arith.nl=true"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: Vale.Def.Words.Seq_s.seq4 Vale.Def.Words_s.nat8
-> FStar.Pervasives.Lemma
(ensures
Lib.ByteSequence.nat_from_bytes_be (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 s) ==
Vale.Def.Types_s.be_bytes_to_nat32 s) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Words.Seq_s.seq4",
"Vale.Def.Words_s.nat8",
"FStar.Calc.calc_finish",
"Prims.nat",
"Prims.eq2",
"Vale.Def.Types_s.be_bytes_to_nat32",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Vale.Def.Words.Four_s.four_to_nat_unfold",
"Vale.Def.Words.Seq_s.seq_to_four_BE",
"Prims.op_Addition",
"FStar.Seq.Base.index",
"FStar.Mul.op_Star",
"Prims.pow2",
"FStar.Seq.Base.slice",
"FStar.UInt8.t",
"FStar.UInt8.v",
"FStar.Seq.Properties.last",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Pervasives.reveal_opaque",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.natN",
"Vale.Def.Words.Four_s.four_to_nat",
"Lib.Sequence.seq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.ByteSequence.nat_from_intseq_be_",
"FStar.Seq.Base.seq",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"Prims._assert",
"Prims.l_True",
"Prims.l_or",
"Lib.IntTypes.uint_t",
"Vale.Def.Words_s.pow2_32",
"Lib.ByteSequence.nat_from_bytes_be",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let lemma_be_to_n_4 (s: seq4 nat8)
: Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) ==
be_bytes_to_nat32 s) =
| let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc ( == ) {
f x <: nat;
( == ) { () }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
( == ) { () }
index s 3 + pow2 8 * f (slice x 0 3);
( == ) { () }
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
( == ) { () }
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
( == ) { () }
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 +
pow2 32 * f (slice x 0 0);
( == ) { () }
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
( == ) { () }
four_to_nat_unfold 8 (seq_to_four_BE s);
( == ) { reveal_opaque (`%four_to_nat) four_to_nat }
be_bytes_to_nat32 s;
} | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.create_row | val create_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> w0:word_t a -> w1:word_t a -> w2:word_t a -> w3:word_t a ->
Stack unit
(requires (fun h -> live h r1))
(ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\
row_v h1 r1 == Spec.( create_row w0 w1 w2 w3 ))) | val create_row: #a:Spec.alg -> #m:m_spec -> r1:row_p a m -> w0:word_t a -> w1:word_t a -> w2:word_t a -> w3:word_t a ->
Stack unit
(requires (fun h -> live h r1))
(ensures (fun h0 _ h1 -> modifies (loc r1) h0 h1 /\
row_v h1 r1 == Spec.( create_row w0 w1 w2 w3 ))) | let create_row #a #m r w0 w1 w2 w3 =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128
| Spec.Blake2B,M256 ->
r.(0ul) <- vec_load4 w0 w1 w2 w3
| _ ->
r.(0ul) <- w0;
r.(1ul) <- w1;
r.(2ul) <- w2;
r.(3ul) <- w3;
let h1 = ST.get() in
Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 74,
"end_line": 247,
"start_col": 0,
"start_line": 235
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200"
noextract inline_for_extraction
let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1
#pop-options
#push-options "--z3rlimit 50"
noextract inline_for_extraction
let permr_row #a #m r1 n =
[@inline_let]
let n0 = n in
[@inline_let]
let n1 = (n+.1ul)%.4ul in
[@inline_let]
let n2 = (n+.2ul)%.4ul in
[@inline_let]
let n3 = (n+.3ul)%.4ul in
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
let v0 : vec_t U32 4 = r1.(0ul) in
let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| Spec.Blake2B,M256 ->
let v0 : vec_t U64 4 = r1.(0ul) in
let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| _ ->
let h0 = ST.get() in
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
let x0 = r1.(n0) in
let x1 = r1.(n1) in
let x2 = r1.(n2) in
let x3 = r1.(n3) in
r1.(0ul) <- x0;
r1.(1ul) <- x1;
r1.(2ul) <- x2;
r1.(3ul) <- x3;
let h1 = ST.get() in
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4])));
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4]))));
Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3));
()
#pop-options
#push-options "--z3rlimit 50"
let create4_lemma #a x0 x1 x2 x3 =
let open Lib.Sequence in
let l : list a = [x0;x1;x2;x3] in
assert_norm (List.Tot.length l = 4);
let s1 : lseq a 4 = of_list l in
let s2 : lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2
#pop-options
noextract inline_for_extraction
let alloc_row a m = create (row_len a m) (zero_element a m) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r1: Hacl.Impl.Blake2.Core.row_p a m ->
w0: Hacl.Impl.Blake2.Core.word_t a ->
w1: Hacl.Impl.Blake2.Core.word_t a ->
w2: Hacl.Impl.Blake2.Core.word_t a ->
w3: Hacl.Impl.Blake2.Core.word_t a
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Hacl.Impl.Blake2.Core.row_p",
"Hacl.Impl.Blake2.Core.word_t",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.op_Array_Assignment",
"Hacl.Impl.Blake2.Core.element_t",
"Hacl.Impl.Blake2.Core.row_len",
"FStar.UInt32.__uint_to_t",
"Lib.IntVector.vec_load4",
"Spec.Blake2.Definitions.wt",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.Sequence.create4",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let create_row #a #m r w0 w1 w2 w3 =
| match a, m with
| Spec.Blake2S, M256 | Spec.Blake2S, M128 | Spec.Blake2B, M256 -> r.(0ul) <- vec_load4 w0 w1 w2 w3
| _ ->
r.(0ul) <- w0;
r.(1ul) <- w1;
r.(2ul) <- w2;
r.(3ul) <- w3;
let h1 = ST.get () in
Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3) | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.alloc_state | val alloc_state: a:Spec.alg -> m:m_spec ->
StackInline (state_p a m)
(requires (fun h -> True))
(ensures (fun h0 r h1 -> stack_allocated r h0 h1 (Lib.Sequence.create (4 * v (row_len a m)) (zero_element a m)) /\
live h1 r)) | val alloc_state: a:Spec.alg -> m:m_spec ->
StackInline (state_p a m)
(requires (fun h -> True))
(ensures (fun h0 r h1 -> stack_allocated r h0 h1 (Lib.Sequence.create (4 * v (row_len a m)) (zero_element a m)) /\
live h1 r)) | let alloc_state a m =
// See git blame below. I never managed to get the previous expression (4ul *.
// row_len a m) to reduce, which generated VLAs in the C code.
create (le_sigh a m) (zero_element a m) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 301,
"start_col": 0,
"start_line": 298
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200"
noextract inline_for_extraction
let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1
#pop-options
#push-options "--z3rlimit 50"
noextract inline_for_extraction
let permr_row #a #m r1 n =
[@inline_let]
let n0 = n in
[@inline_let]
let n1 = (n+.1ul)%.4ul in
[@inline_let]
let n2 = (n+.2ul)%.4ul in
[@inline_let]
let n3 = (n+.3ul)%.4ul in
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
let v0 : vec_t U32 4 = r1.(0ul) in
let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| Spec.Blake2B,M256 ->
let v0 : vec_t U64 4 = r1.(0ul) in
let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| _ ->
let h0 = ST.get() in
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
let x0 = r1.(n0) in
let x1 = r1.(n1) in
let x2 = r1.(n2) in
let x3 = r1.(n3) in
r1.(0ul) <- x0;
r1.(1ul) <- x1;
r1.(2ul) <- x2;
r1.(3ul) <- x3;
let h1 = ST.get() in
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4])));
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4]))));
Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3));
()
#pop-options
#push-options "--z3rlimit 50"
let create4_lemma #a x0 x1 x2 x3 =
let open Lib.Sequence in
let l : list a = [x0;x1;x2;x3] in
assert_norm (List.Tot.length l = 4);
let s1 : lseq a 4 = of_list l in
let s2 : lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2
#pop-options
noextract inline_for_extraction
let alloc_row a m = create (row_len a m) (zero_element a m)
noextract inline_for_extraction
let create_row #a #m r w0 w1 w2 w3 =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128
| Spec.Blake2B,M256 ->
r.(0ul) <- vec_load4 w0 w1 w2 w3
| _ ->
r.(0ul) <- w0;
r.(1ul) <- w1;
r.(2ul) <- w2;
r.(3ul) <- w3;
let h1 = ST.get() in
Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3)
noextract inline_for_extraction
let load_row #a #m r ws = create_row r ws.(0ul) ws.(1ul) ws.(2ul) ws.(3ul)
noextract inline_for_extraction
let store_row #a #m b r =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
vec_store_le #U32 #4 b r.(0ul)
| Spec.Blake2B,M256 ->
vec_store_le #U64 #4 b r.(0ul)
| _ ->
uints_to_bytes_le #(Spec.wt a) 4ul b r
noextract inline_for_extraction
let store_row32 #a #m b r =
push_frame();
let h0 = ST.get() in
let b8 = create (size_row a) (u8 0) in
store_row b8 r;
let h1 = ST.get() in
uints_from_bytes_le b b8;
let h2 = ST.get() in
assert (as_seq h1 b8 == Lib.ByteSequence.uints_to_bytes_le #(Spec.wt a) (row_v h0 r));
assert (as_seq h2 b == Lib.ByteSequence.uints_from_bytes_le #(Spec.wt a) (as_seq h1 b8));
Lib.Sequence.eq_intro (as_seq h2 b) (Spec.load_row (as_seq h2 b));
assert (Spec.load_row (as_seq h2 b) ==
Lib.ByteSequence.uints_from_bytes_le (as_seq h1 b8));
Lib.ByteSequence.lemma_uints_to_from_bytes_le_preserves_value (row_v h0 r);
pop_frame()
noextract inline_for_extraction
let gather_row #a #ms r m i0 i1 i2 i3 =
create_row r m.(i0) m.(i1) m.(i2) m.(i3)
noextract inline_for_extraction
let le_sigh (a:Spec.alg) (m:m_spec): x:size_t { x == 4ul *. row_len a m } =
let open FStar.Mul in
assert_norm ((4 * 1) % pow2 32 = 4);
assert_norm ((4 * 4) % pow2 32 = 16);
Lib.IntTypes.mul_mod_lemma 4ul 1ul;
Lib.IntTypes.mul_mod_lemma 4ul 4ul;
match a,m with
| Spec.Blake2S,M128 -> 4ul
| Spec.Blake2S,M256 -> 4ul
| Spec.Blake2B,M256 -> 4ul
| _ -> 16ul | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Blake2.Definitions.alg -> m: Hacl.Impl.Blake2.Core.m_spec
-> FStar.HyperStack.ST.StackInline (Hacl.Impl.Blake2.Core.state_p a m) | FStar.HyperStack.ST.StackInline | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Lib.Buffer.create",
"Hacl.Impl.Blake2.Core.element_t",
"Hacl.Impl.Blake2.Core.le_sigh",
"Hacl.Impl.Blake2.Core.zero_element",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Blake2.Core.state_p"
] | [] | false | true | false | false | false | let alloc_state a m =
| create (le_sigh a m) (zero_element a m) | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.store_row | val store_row: #a:Spec.alg -> #m:m_spec -> b:lbuffer uint8 (size_row a) -> r:row_p a m ->
Stack unit
(requires (fun h -> live h r /\ live h b /\ disjoint r b))
(ensures (fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (row_v h0 r))) | val store_row: #a:Spec.alg -> #m:m_spec -> b:lbuffer uint8 (size_row a) -> r:row_p a m ->
Stack unit
(requires (fun h -> live h r /\ live h b /\ disjoint r b))
(ensures (fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (row_v h0 r))) | let store_row #a #m b r =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
vec_store_le #U32 #4 b r.(0ul)
| Spec.Blake2B,M256 ->
vec_store_le #U64 #4 b r.(0ul)
| _ ->
uints_to_bytes_le #(Spec.wt a) 4ul b r | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 261,
"start_col": 0,
"start_line": 253
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200"
noextract inline_for_extraction
let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1
#pop-options
#push-options "--z3rlimit 50"
noextract inline_for_extraction
let permr_row #a #m r1 n =
[@inline_let]
let n0 = n in
[@inline_let]
let n1 = (n+.1ul)%.4ul in
[@inline_let]
let n2 = (n+.2ul)%.4ul in
[@inline_let]
let n3 = (n+.3ul)%.4ul in
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
let v0 : vec_t U32 4 = r1.(0ul) in
let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| Spec.Blake2B,M256 ->
let v0 : vec_t U64 4 = r1.(0ul) in
let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| _ ->
let h0 = ST.get() in
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
let x0 = r1.(n0) in
let x1 = r1.(n1) in
let x2 = r1.(n2) in
let x3 = r1.(n3) in
r1.(0ul) <- x0;
r1.(1ul) <- x1;
r1.(2ul) <- x2;
r1.(3ul) <- x3;
let h1 = ST.get() in
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4])));
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4]))));
Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3));
()
#pop-options
#push-options "--z3rlimit 50"
let create4_lemma #a x0 x1 x2 x3 =
let open Lib.Sequence in
let l : list a = [x0;x1;x2;x3] in
assert_norm (List.Tot.length l = 4);
let s1 : lseq a 4 = of_list l in
let s2 : lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2
#pop-options
noextract inline_for_extraction
let alloc_row a m = create (row_len a m) (zero_element a m)
noextract inline_for_extraction
let create_row #a #m r w0 w1 w2 w3 =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128
| Spec.Blake2B,M256 ->
r.(0ul) <- vec_load4 w0 w1 w2 w3
| _ ->
r.(0ul) <- w0;
r.(1ul) <- w1;
r.(2ul) <- w2;
r.(3ul) <- w3;
let h1 = ST.get() in
Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3)
noextract inline_for_extraction
let load_row #a #m r ws = create_row r ws.(0ul) ws.(1ul) ws.(2ul) ws.(3ul) | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Hacl.Impl.Blake2.Core.size_row a) ->
r: Hacl.Impl.Blake2.Core.row_p a m
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Impl.Blake2.Core.size_row",
"Hacl.Impl.Blake2.Core.row_p",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntVector.vec_store_le",
"Lib.IntTypes.U32",
"Prims.unit",
"Lib.IntVector.vec_t",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT",
"Hacl.Impl.Blake2.Core.element_t",
"Hacl.Impl.Blake2.Core.row_len",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.U64",
"FStar.Pervasives.Native.tuple2",
"Lib.ByteBuffer.uints_to_bytes_le",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.SEC"
] | [] | false | true | false | false | false | let store_row #a #m b r =
| match a, m with
| Spec.Blake2S, M256 | Spec.Blake2S, M128 -> vec_store_le #U32 #4 b r.(0ul)
| Spec.Blake2B, M256 -> vec_store_le #U64 #4 b r.(0ul)
| _ -> uints_to_bytes_le #(Spec.wt a) 4ul b r | false |
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.state_v_eq_lemma | val state_v_eq_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st1:state_p a m -> st2:state_p a m ->
Lemma (requires (as_seq h0 st1 == as_seq h1 st2))
(ensures (state_v h0 st1 == state_v h1 st2))
[SMTPat (state_v #a #m h0 st1); SMTPat (state_v #a #m h1 st2)] | val state_v_eq_lemma: #a:Spec.alg -> #m:m_spec -> h0:mem -> h1:mem -> st1:state_p a m -> st2:state_p a m ->
Lemma (requires (as_seq h0 st1 == as_seq h1 st2))
(ensures (state_v h0 st1 == state_v h1 st2))
[SMTPat (state_v #a #m h0 st1); SMTPat (state_v #a #m h1 st2)] | let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2) | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 57,
"end_line": 111,
"start_col": 0,
"start_line": 98
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3 | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_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 |
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
st1: Hacl.Impl.Blake2.Core.state_p a m ->
st2: Hacl.Impl.Blake2.Core.state_p a m
-> FStar.Pervasives.Lemma (requires Lib.Buffer.as_seq h0 st1 == Lib.Buffer.as_seq h1 st2)
(ensures Hacl.Impl.Blake2.Core.state_v h0 st1 == Hacl.Impl.Blake2.Core.state_v h1 st2)
[SMTPat (Hacl.Impl.Blake2.Core.state_v h0 st1); SMTPat (Hacl.Impl.Blake2.Core.state_v h1 st2)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Blake2.Core.state_p",
"Lib.Sequence.eq_intro",
"Spec.Blake2.Definitions.row",
"Hacl.Impl.Blake2.Core.state_v",
"Prims.unit",
"Hacl.Impl.Blake2.Core.row_v_lemma",
"Hacl.Impl.Blake2.Core.g_rowi",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Blake2.Core.element_t",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Blake2.Core.row_len",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.slice",
"Lib.IntTypes.op_Star_Dot",
"LowStar.Monotonic.Buffer.as_seq_gsub",
"LowStar.Buffer.trivial_preorder",
"Prims.int"
] | [] | true | false | true | false | false | let state_v_eq_lemma #a #m h0 h1 st1 st2 =
| assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_
#(LowStar.Buffer.trivial_preorder (element_t a m))
#(LowStar.Buffer.trivial_preorder (element_t a m))
h0
st1
0ul
(row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) ==
Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) ==
Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) ==
Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2) | false |
Pulse.Extract.Main.fst | Pulse.Extract.Main.name | val name : Type0 | let name = ppname & nat | {
"file_name": "lib/steel/pulse/Pulse.Extract.Main.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 23,
"end_line": 44,
"start_col": 0,
"start_line": 44
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Extract.Main
open Pulse.Syntax.Base
open Pulse.Syntax.Pure
open Pulse.Extract.CompilerLib
open Pulse.Syntax.Printer
open FStar.List.Tot
module L = FStar.List.Tot
module R = FStar.Reflection
module RT = FStar.Reflection.Typing
module T = FStar.Tactics.V2
module RB = Pulse.Readback
module Elab = Pulse.Elaborate.Pure
module E = Pulse.Typing.Env
module LN = Pulse.Syntax.Naming
module RU = Pulse.RuntimeUtils
module ECL = Pulse.Extract.CompilerLib
exception Extraction_failure of string
noeq
type env = {
uenv_inner: uenv;
coreenv: Pulse.Typing.Env.env
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Pure.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Naming.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Readback.fsti.checked",
"Pulse.Extract.CompilerLib.fsti.checked",
"Pulse.Elaborate.Pure.fst.checked",
"Pulse.Checker.Match.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Reflection.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Pulse.Extract.Main.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": "ECL"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Naming",
"short_module": "LN"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Pulse.Elaborate.Pure",
"short_module": "Elab"
},
{
"abbrev": true,
"full_module": "Pulse.Readback",
"short_module": "RB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Reflection",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": 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.Pervasives.Native.tuple2",
"Pulse.Syntax.Base.ppname",
"Prims.nat"
] | [] | false | false | false | true | true | let name =
| ppname & nat | false |
|
Hacl.Impl.Blake2.Core.fst | Hacl.Impl.Blake2.Core.store_row32 | val store_row32: #a:Spec.alg -> #m:m_spec -> b:lbuffer (word_t a) 4ul -> r:row_p a m ->
Stack unit
(requires (fun h -> live h r /\ live h b /\ disjoint r b))
(ensures (fun h0 _ h1 -> modifies (loc b) h0 h1 /\
Spec.( load_row (as_seq h1 b)) == row_v h0 r)) | val store_row32: #a:Spec.alg -> #m:m_spec -> b:lbuffer (word_t a) 4ul -> r:row_p a m ->
Stack unit
(requires (fun h -> live h r /\ live h b /\ disjoint r b))
(ensures (fun h0 _ h1 -> modifies (loc b) h0 h1 /\
Spec.( load_row (as_seq h1 b)) == row_v h0 r)) | let store_row32 #a #m b r =
push_frame();
let h0 = ST.get() in
let b8 = create (size_row a) (u8 0) in
store_row b8 r;
let h1 = ST.get() in
uints_from_bytes_le b b8;
let h2 = ST.get() in
assert (as_seq h1 b8 == Lib.ByteSequence.uints_to_bytes_le #(Spec.wt a) (row_v h0 r));
assert (as_seq h2 b == Lib.ByteSequence.uints_from_bytes_le #(Spec.wt a) (as_seq h1 b8));
Lib.Sequence.eq_intro (as_seq h2 b) (Spec.load_row (as_seq h2 b));
assert (Spec.load_row (as_seq h2 b) ==
Lib.ByteSequence.uints_from_bytes_le (as_seq h1 b8));
Lib.ByteSequence.lemma_uints_to_from_bytes_le_preserves_value (row_v h0 r);
pop_frame() | {
"file_name": "code/blake2/Hacl.Impl.Blake2.Core.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 278,
"start_col": 0,
"start_line": 264
} | module Hacl.Impl.Blake2.Core
module ST = FStar.HyperStack.ST
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
module Spec = Spec.Blake2
#set-options "--max_fuel 0 --max_ifuel 1"
noextract inline_for_extraction
let zero_element (a:Spec.alg) (m:m_spec) : element_t a m =
match a,m with
| Spec.Blake2S,M128 -> (vec_zero U32 4)
| Spec.Blake2S,M256 -> (vec_zero U32 4)
| Spec.Blake2B,M256 -> (vec_zero U64 4)
| _ -> Spec.zero a
noextract inline_for_extraction
let row_v #a #m h r =
match a,m with
| Spec.Blake2S,M128 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2S,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| Spec.Blake2B,M256 -> vec_v (Lib.Sequence.index (as_seq h r) 0)
| _ -> as_seq h r
let row_v_lemma #a #m h0 h1 r1 r2 = ()
let create_default_params a salt personal =
match a with
| Spec.Blake2S -> {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal } <: blake2s_params
| Spec.Blake2B -> {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt; personal }
#push-options "--z3rlimit 50"
let g_rowi_disjoint #a #m st idx1 idx2 =
if idx1 <. idx2 then (
assert (v (idx1 *. row_len a m) + v (row_len a m) <= v (idx2 *. row_len a m));
assert (g_rowi st idx1 ==
gsub st (idx1 *. row_len a m) (row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m))
)
else if idx2 <. idx1 then (
assert (v (idx2 *. row_len a m) + v (row_len a m) <= v (idx1 *. row_len a m));
assert (g_rowi st idx2 ==
gsub st (idx2 *. row_len a m) (row_len a m));
LowStar.Monotonic.Buffer.loc_disjoint_gsub_buffer #_ #((LowStar.Buffer.trivial_preorder (element_t a m))) #((LowStar.Buffer.trivial_preorder (element_t a m))) st (idx1 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)) (idx2 *. row_len a m) (row_len a m) (LowStar.Buffer.trivial_preorder (element_t a m)))
else ()
let g_rowi_unchanged #a #m h0 h1 st i =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h1 st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
let g_rowi_disjoint_other #a #m #b st i x =
assert (v (i *. row_len a m) + v (row_len a m) <= length st);
LowStar.Monotonic.Buffer.loc_includes_gsub_buffer_r' #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) st (i *. row_len a m) (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m))
#pop-options
inline_for_extraction noextract
let state_v (#a:Spec.alg) (#m:m_spec) (h:mem) (st:state_p a m) : GTot (Spec.state a) =
let r0 = row_v h (g_rowi st 0ul) in
let r1 = row_v h (g_rowi st 1ul) in
let r2 = row_v h (g_rowi st 2ul) in
let r3 = row_v h (g_rowi st 3ul) in
Lib.Sequence.create4 r0 r1 r2 r3
#push-options "--z3rlimit 100"
let state_v_eq_lemma #a #m h0 h1 st1 st2 =
assert (v (0ul *. row_len a m) == 0);
LowStar.Monotonic.Buffer.as_seq_gsub #_ #(LowStar.Buffer.trivial_preorder (element_t a m)) #(LowStar.Buffer.trivial_preorder (element_t a m)) h0 st1 0ul (row_len a m)
(LowStar.Buffer.trivial_preorder (element_t a m));
assert (as_seq h0 (g_rowi st1 0ul) == Seq.slice (as_seq h0 st1) 0 (v (row_len a m)));
assert (as_seq h0 (g_rowi st1 1ul) == Seq.slice (as_seq h0 st1) (v (1ul *. row_len a m)) (v (2ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 2ul) == Seq.slice (as_seq h0 st1) (v (2ul *. row_len a m)) (v (3ul *. row_len a m)));
assert (as_seq h0 (g_rowi st1 3ul) == Seq.slice (as_seq h0 st1) (v (3ul *. row_len a m)) (v (4ul *. row_len a m)));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 0ul)) (as_seq h1 (g_rowi st2 0ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 1ul)) (as_seq h1 (g_rowi st2 1ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 2ul)) (as_seq h1 (g_rowi st2 2ul));
Lib.Sequence.eq_intro (as_seq h0 (g_rowi st1 3ul)) (as_seq h1 (g_rowi st2 3ul));
row_v_lemma h0 h1 (g_rowi st1 0ul) (g_rowi st2 0ul);
Lib.Sequence.eq_intro (state_v h0 st1) (state_v h1 st2)
#pop-options
let state_v_rowi_lemma #a #m h st i = ()
let state_v_live_rowi_lemma #a #m h st i = ()
#push-options "--z3rlimit 50"
let modifies_one_row a m h0 h1 st i j =
let ri = g_rowi st i in
let rj = g_rowi st j in
assert (live h0 ri);
assert (live h0 rj);
assert (modifies (loc ri) h0 h1);
assert (disjoint rj ri);
assert (as_seq h1 rj == as_seq h0 rj)
let modifies_row_state a m h0 h1 st i =
Lib.Sequence.(eq_intro (state_v h1 st) ((state_v h0 st).[v i] <- row_v h1 (g_rowi st i)))
#pop-options
noextract inline_for_extraction
let rowi (#a:Spec.alg) (#m:m_spec) (st:state_p a m) (idx:index_t) =
sub st (idx *. row_len a m) (row_len a m)
noextract inline_for_extraction
let xor_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_xor #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_xor #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (logxor #(Spec.wt a) #SEC) r1 r2
noextract inline_for_extraction
let add_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_add_mod #U32 #4 r1.(0ul) r2.(0ul)
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_add_mod #U64 #4 r1.(0ul) r2.(0ul)
| _ -> map2T 4ul r1 (add_mod #(Spec.wt a) #SEC) r1 r2
#push-options "--z3rlimit 200"
noextract inline_for_extraction
let ror_row #a #m r1 r2 =
match a,m with
| Spec.Blake2S,M128 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2S,M256 ->
r1.(0ul) <- vec_rotate_right #U32 #4 r1.(0ul) r2
| Spec.Blake2B,M256 ->
r1.(0ul) <- vec_rotate_right #U64 #4 r1.(0ul) r2
| _ ->
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
mapT 4ul r1 (rotate_right_i r2) r1
#pop-options
#push-options "--z3rlimit 50"
noextract inline_for_extraction
let permr_row #a #m r1 n =
[@inline_let]
let n0 = n in
[@inline_let]
let n1 = (n+.1ul)%.4ul in
[@inline_let]
let n2 = (n+.2ul)%.4ul in
[@inline_let]
let n3 = (n+.3ul)%.4ul in
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
let v0 : vec_t U32 4 = r1.(0ul) in
let v1 : vec_t U32 4 = vec_rotate_right_lanes #U32 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| Spec.Blake2B,M256 ->
let v0 : vec_t U64 4 = r1.(0ul) in
let v1 : vec_t U64 4 = vec_rotate_right_lanes #U64 v0 n0 in
Lib.Sequence.(eq_intro (create4 (vec_v v0).[v n0] (vec_v v0).[v n1] (vec_v v0).[v n2] (vec_v v0).[v n3]) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
Lib.Sequence.(eq_intro (Spec.rotr (vec_v v0) (v n)) (Lib.Sequence.(createi 4 (fun i -> (vec_v v0).[(i+v n)%4]))));
r1.(0ul) <- v1
| _ ->
let h0 = ST.get() in
let r1:lbuffer (Spec.word_t a) 4ul = r1 in
let x0 = r1.(n0) in
let x1 = r1.(n1) in
let x2 = r1.(n2) in
let x3 = r1.(n3) in
r1.(0ul) <- x0;
r1.(1ul) <- x1;
r1.(2ul) <- x2;
r1.(3ul) <- x3;
let h1 = ST.get() in
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (create4 x0 x1 x2 x3) (createi 4 (fun i -> s0.[(i+v n)%4])));
Lib.Sequence.(let s0 = as_seq h0 r1 in eq_intro (Spec.rotr s0 (v n)) (Lib.Sequence.(createi 4 (fun i -> s0.[(i+v n)%4]))));
Lib.Sequence.(eq_intro (as_seq h1 r1) (create4 x0 x1 x2 x3));
()
#pop-options
#push-options "--z3rlimit 50"
let create4_lemma #a x0 x1 x2 x3 =
let open Lib.Sequence in
let l : list a = [x0;x1;x2;x3] in
assert_norm (List.Tot.length l = 4);
let s1 : lseq a 4 = of_list l in
let s2 : lseq a 4 = create4 x0 x1 x2 x3 in
Seq.intro_of_list s2 l;
eq_intro s1 s2
#pop-options
noextract inline_for_extraction
let alloc_row a m = create (row_len a m) (zero_element a m)
noextract inline_for_extraction
let create_row #a #m r w0 w1 w2 w3 =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128
| Spec.Blake2B,M256 ->
r.(0ul) <- vec_load4 w0 w1 w2 w3
| _ ->
r.(0ul) <- w0;
r.(1ul) <- w1;
r.(2ul) <- w2;
r.(3ul) <- w3;
let h1 = ST.get() in
Lib.Sequence.eq_intro (as_seq h1 r) (Lib.Sequence.create4 w0 w1 w2 w3)
noextract inline_for_extraction
let load_row #a #m r ws = create_row r ws.(0ul) ws.(1ul) ws.(2ul) ws.(3ul)
noextract inline_for_extraction
let store_row #a #m b r =
match a,m with
| Spec.Blake2S,M256
| Spec.Blake2S,M128 ->
vec_store_le #U32 #4 b r.(0ul)
| Spec.Blake2B,M256 ->
vec_store_le #U64 #4 b r.(0ul)
| _ ->
uints_to_bytes_le #(Spec.wt a) 4ul b r | {
"checked_file": "/",
"dependencies": [
"Spec.Blake2.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Blake2.Core.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Blake2",
"short_module": "Spec"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Blake2",
"short_module": null
},
{
"abbrev": 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": 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": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Lib.Buffer.lbuffer (Hacl.Impl.Blake2.Core.word_t a) 4ul -> r: Hacl.Impl.Blake2.Core.row_p a m
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Spec.Blake2.Definitions.alg",
"Hacl.Impl.Blake2.Core.m_spec",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Blake2.Core.word_t",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Blake2.Core.row_p",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Lib.ByteSequence.lemma_uints_to_from_bytes_le_preserves_value",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.SEC",
"Hacl.Impl.Blake2.Core.row_v",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint_t",
"Spec.Blake2.Definitions.load_row",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.ByteSequence.uints_from_bytes_le",
"Lib.IntTypes.uint8",
"Hacl.Impl.Blake2.Core.size_row",
"Lib.Sequence.eq_intro",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Lib.IntTypes.U8",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.ByteSequence.uints_to_bytes_le",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.ByteBuffer.uints_from_bytes_le",
"Hacl.Impl.Blake2.Core.store_row",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let store_row32 #a #m b r =
| push_frame ();
let h0 = ST.get () in
let b8 = create (size_row a) (u8 0) in
store_row b8 r;
let h1 = ST.get () in
uints_from_bytes_le b b8;
let h2 = ST.get () in
assert (as_seq h1 b8 == Lib.ByteSequence.uints_to_bytes_le #(Spec.wt a) (row_v h0 r));
assert (as_seq h2 b == Lib.ByteSequence.uints_from_bytes_le #(Spec.wt a) (as_seq h1 b8));
Lib.Sequence.eq_intro (as_seq h2 b) (Spec.load_row (as_seq h2 b));
assert (Spec.load_row (as_seq h2 b) == Lib.ByteSequence.uints_from_bytes_le (as_seq h1 b8));
Lib.ByteSequence.lemma_uints_to_from_bytes_le_preserves_value (row_v h0 r);
pop_frame () | false |
Pulse.Extract.Main.fst | Pulse.Extract.Main.uenv_of_env | val uenv_of_env : g: Pulse.Extract.Main.env -> Pulse.Extract.CompilerLib.uenv | let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) | {
"file_name": "lib/steel/pulse/Pulse.Extract.Main.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 65,
"end_line": 48,
"start_col": 0,
"start_line": 48
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Extract.Main
open Pulse.Syntax.Base
open Pulse.Syntax.Pure
open Pulse.Extract.CompilerLib
open Pulse.Syntax.Printer
open FStar.List.Tot
module L = FStar.List.Tot
module R = FStar.Reflection
module RT = FStar.Reflection.Typing
module T = FStar.Tactics.V2
module RB = Pulse.Readback
module Elab = Pulse.Elaborate.Pure
module E = Pulse.Typing.Env
module LN = Pulse.Syntax.Naming
module RU = Pulse.RuntimeUtils
module ECL = Pulse.Extract.CompilerLib
exception Extraction_failure of string
noeq
type env = {
uenv_inner: uenv;
coreenv: Pulse.Typing.Env.env
}
let name = ppname & nat
let topenv_of_env (g:env) = E.fstar_env g.coreenv | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Pure.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Naming.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Readback.fsti.checked",
"Pulse.Extract.CompilerLib.fsti.checked",
"Pulse.Elaborate.Pure.fst.checked",
"Pulse.Checker.Match.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Reflection.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Pulse.Extract.Main.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": "ECL"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Naming",
"short_module": "LN"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Pulse.Elaborate.Pure",
"short_module": "Elab"
},
{
"abbrev": true,
"full_module": "Pulse.Readback",
"short_module": "RB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Reflection",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": 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 | g: Pulse.Extract.Main.env -> Pulse.Extract.CompilerLib.uenv | Prims.Tot | [
"total"
] | [] | [
"Pulse.Extract.Main.env",
"Pulse.Extract.CompilerLib.set_tcenv",
"Pulse.Extract.Main.__proj__Mkenv__item__uenv_inner",
"Pulse.Extract.Main.tcenv_of_env",
"Pulse.Extract.CompilerLib.uenv"
] | [] | false | false | false | true | false | let uenv_of_env (g: env) =
| set_tcenv g.uenv_inner (tcenv_of_env g) | false |
|
LList.fst | LList.datas | val datas (#a: Type) (l: list (cell a)) : list a | val datas (#a: Type) (l: list (cell a)) : list a | let rec datas (#a:Type) (l:list (cell a)) : list a =
match l with
| [] -> []
| hd::tl -> data hd :: datas tl | {
"file_name": "share/steel/examples/steel/LList.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 33,
"end_line": 15,
"start_col": 0,
"start_line": 12
} | module LList
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.FractionalPermission
open Steel.Reference
include LList.Invariant
module L = FStar.List.Tot.Base
#set-options "--ide_id_info_off" | {
"checked_file": "/",
"dependencies": [
"Steel.Reference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"LList.Invariant.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "LList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LList.Invariant",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "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 | l: Prims.list (LList.Invariant.cell a) -> Prims.list a | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"LList.Invariant.cell",
"Prims.Nil",
"Prims.Cons",
"LList.Invariant.data",
"LList.datas"
] | [
"recursion"
] | false | false | false | true | false | let rec datas (#a: Type) (l: list (cell a)) : list a =
| match l with
| [] -> []
| hd :: tl -> data hd :: datas tl | false |
Pulse.Extract.Main.fst | Pulse.Extract.Main.term_as_mlexpr | val term_as_mlexpr (g: env) (t: term) : T.Tac mlexpr | val term_as_mlexpr (g: env) (t: term) : T.Tac mlexpr | let term_as_mlexpr (g:env) (t:term)
: T.Tac mlexpr
= let t = Elab.elab_term t in
let uenv = uenv_of_env g in
let t = normalize_for_extraction uenv t in
let mlt, _, _ = term_as_mlexpr uenv t in
mlt | {
"file_name": "lib/steel/pulse/Pulse.Extract.Main.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 7,
"end_line": 62,
"start_col": 0,
"start_line": 56
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Extract.Main
open Pulse.Syntax.Base
open Pulse.Syntax.Pure
open Pulse.Extract.CompilerLib
open Pulse.Syntax.Printer
open FStar.List.Tot
module L = FStar.List.Tot
module R = FStar.Reflection
module RT = FStar.Reflection.Typing
module T = FStar.Tactics.V2
module RB = Pulse.Readback
module Elab = Pulse.Elaborate.Pure
module E = Pulse.Typing.Env
module LN = Pulse.Syntax.Naming
module RU = Pulse.RuntimeUtils
module ECL = Pulse.Extract.CompilerLib
exception Extraction_failure of string
noeq
type env = {
uenv_inner: uenv;
coreenv: Pulse.Typing.Env.env
}
let name = ppname & nat
let topenv_of_env (g:env) = E.fstar_env g.coreenv
let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv
let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g)
let debug (g:env) (f: unit -> T.Tac string)
: T.Tac unit
= if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction"
then T.print (f()) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Pure.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Naming.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Readback.fsti.checked",
"Pulse.Extract.CompilerLib.fsti.checked",
"Pulse.Elaborate.Pure.fst.checked",
"Pulse.Checker.Match.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Reflection.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Pulse.Extract.Main.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": "ECL"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Naming",
"short_module": "LN"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Pulse.Elaborate.Pure",
"short_module": "Elab"
},
{
"abbrev": true,
"full_module": "Pulse.Readback",
"short_module": "RB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Reflection",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": 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 | g: Pulse.Extract.Main.env -> t: Pulse.Syntax.Base.term
-> FStar.Tactics.Effect.Tac Pulse.Extract.CompilerLib.mlexpr | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Extract.Main.env",
"Pulse.Syntax.Base.term",
"Pulse.Extract.CompilerLib.mlexpr",
"Pulse.Extract.CompilerLib.e_tag",
"Pulse.Extract.CompilerLib.mlty",
"FStar.Pervasives.Native.tuple3",
"Pulse.Extract.CompilerLib.term_as_mlexpr",
"FStar.Tactics.NamedView.term",
"Pulse.Extract.CompilerLib.normalize_for_extraction",
"Pulse.Extract.CompilerLib.uenv",
"Pulse.Extract.Main.uenv_of_env",
"FStar.Stubs.Reflection.Types.term",
"Pulse.Elaborate.Pure.elab_term"
] | [] | false | true | false | false | false | let term_as_mlexpr (g: env) (t: term) : T.Tac mlexpr =
| let t = Elab.elab_term t in
let uenv = uenv_of_env g in
let t = normalize_for_extraction uenv t in
let mlt, _, _ = term_as_mlexpr uenv t in
mlt | false |
Pulse.Extract.Main.fst | Pulse.Extract.Main.topenv_of_env | val topenv_of_env : g: Pulse.Extract.Main.env -> FStar.Reflection.Typing.fstar_top_env | let topenv_of_env (g:env) = E.fstar_env g.coreenv | {
"file_name": "lib/steel/pulse/Pulse.Extract.Main.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 49,
"end_line": 46,
"start_col": 0,
"start_line": 46
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Extract.Main
open Pulse.Syntax.Base
open Pulse.Syntax.Pure
open Pulse.Extract.CompilerLib
open Pulse.Syntax.Printer
open FStar.List.Tot
module L = FStar.List.Tot
module R = FStar.Reflection
module RT = FStar.Reflection.Typing
module T = FStar.Tactics.V2
module RB = Pulse.Readback
module Elab = Pulse.Elaborate.Pure
module E = Pulse.Typing.Env
module LN = Pulse.Syntax.Naming
module RU = Pulse.RuntimeUtils
module ECL = Pulse.Extract.CompilerLib
exception Extraction_failure of string
noeq
type env = {
uenv_inner: uenv;
coreenv: Pulse.Typing.Env.env
}
let name = ppname & nat | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Pure.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Naming.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Readback.fsti.checked",
"Pulse.Extract.CompilerLib.fsti.checked",
"Pulse.Elaborate.Pure.fst.checked",
"Pulse.Checker.Match.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Reflection.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Pulse.Extract.Main.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": "ECL"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Naming",
"short_module": "LN"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Pulse.Elaborate.Pure",
"short_module": "Elab"
},
{
"abbrev": true,
"full_module": "Pulse.Readback",
"short_module": "RB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Reflection",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": 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 | g: Pulse.Extract.Main.env -> FStar.Reflection.Typing.fstar_top_env | Prims.Tot | [
"total"
] | [] | [
"Pulse.Extract.Main.env",
"Pulse.Typing.Env.fstar_env",
"Pulse.Extract.Main.__proj__Mkenv__item__coreenv",
"FStar.Reflection.Typing.fstar_top_env"
] | [] | false | false | false | true | false | let topenv_of_env (g: env) =
| E.fstar_env g.coreenv | false |
|
Pulse.Extract.Main.fst | Pulse.Extract.Main.debug | val debug (g: env) (f: (unit -> T.Tac string)) : T.Tac unit | val debug (g: env) (f: (unit -> T.Tac string)) : T.Tac unit | let debug (g:env) (f: unit -> T.Tac string)
: T.Tac unit
= if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction"
then T.print (f()) | {
"file_name": "lib/steel/pulse/Pulse.Extract.Main.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 22,
"end_line": 53,
"start_col": 0,
"start_line": 50
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Extract.Main
open Pulse.Syntax.Base
open Pulse.Syntax.Pure
open Pulse.Extract.CompilerLib
open Pulse.Syntax.Printer
open FStar.List.Tot
module L = FStar.List.Tot
module R = FStar.Reflection
module RT = FStar.Reflection.Typing
module T = FStar.Tactics.V2
module RB = Pulse.Readback
module Elab = Pulse.Elaborate.Pure
module E = Pulse.Typing.Env
module LN = Pulse.Syntax.Naming
module RU = Pulse.RuntimeUtils
module ECL = Pulse.Extract.CompilerLib
exception Extraction_failure of string
noeq
type env = {
uenv_inner: uenv;
coreenv: Pulse.Typing.Env.env
}
let name = ppname & nat
let topenv_of_env (g:env) = E.fstar_env g.coreenv
let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv
let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Pure.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Naming.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Readback.fsti.checked",
"Pulse.Extract.CompilerLib.fsti.checked",
"Pulse.Elaborate.Pure.fst.checked",
"Pulse.Checker.Match.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Reflection.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Pulse.Extract.Main.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": "ECL"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Naming",
"short_module": "LN"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Pulse.Elaborate.Pure",
"short_module": "Elab"
},
{
"abbrev": true,
"full_module": "Pulse.Readback",
"short_module": "RB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Reflection",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": 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 | g: Pulse.Extract.Main.env -> f: (_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.string)
-> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Extract.Main.env",
"Prims.unit",
"Prims.string",
"Pulse.RuntimeUtils.debug_at_level",
"Pulse.Typing.Env.fstar_env",
"Pulse.Extract.Main.__proj__Mkenv__item__coreenv",
"FStar.Stubs.Tactics.V2.Builtins.print",
"Prims.bool"
] | [] | false | true | false | false | false | let debug (g: env) (f: (unit -> T.Tac string)) : T.Tac unit =
| if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction" then T.print (f ()) | false |
Hacl.Impl.P256.PointAdd.fst | Hacl.Impl.P256.PointAdd.point_add | val point_add: res:point -> p:point -> q:point -> Stack unit
(requires fun h ->
live h p /\ live h q /\ live h res /\
eq_or_disjoint p q /\ eq_or_disjoint q res /\ eq_or_disjoint p res /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
point_inv h1 res /\
from_mont_point (as_point_nat h1 res) ==
S.point_add (from_mont_point (as_point_nat h0 p)) (from_mont_point (as_point_nat h0 q))) | val point_add: res:point -> p:point -> q:point -> Stack unit
(requires fun h ->
live h p /\ live h q /\ live h res /\
eq_or_disjoint p q /\ eq_or_disjoint q res /\ eq_or_disjoint p res /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
point_inv h1 res /\
from_mont_point (as_point_nat h1 res) ==
S.point_add (from_mont_point (as_point_nat h0 p)) (from_mont_point (as_point_nat h0 q))) | let point_add res p q =
push_frame ();
let tmp = create 36ul (u64 0) in
let t0 = sub tmp 0ul 24ul in
let t1 = sub tmp 24ul 12ul in
point_add_noalloc t0 t1 p q;
copy res t1;
pop_frame () | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 308,
"start_col": 0,
"start_line": 301
} | module Hacl.Impl.P256.PointAdd
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
module S = Spec.P256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_1 (t0 t1 t2 t3 t4:felem) (p q:point) : Stack unit
(requires fun h ->
live h t0 /\ live h t1 /\ live h t2 /\
live h t3 /\ live h t4 /\ live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint
[loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
eq_or_disjoint p q /\ disjoint p t0 /\ disjoint p t1 /\
disjoint p t2 /\ disjoint p t3 /\ disjoint p t4 /\
disjoint q t0 /\ disjoint q t1 /\ disjoint q t2 /\
disjoint q t3 /\ disjoint q t4 /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc t0 |+| loc t1 |+| loc t2 |+| loc t3 |+| loc t4) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 t3 < S.prime /\
as_nat h1 t4 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = S.fmul x1 x2 in
let t1_s = S.fmul y1 y2 in
let t2_s = S.fmul z1 z2 in
let t3_s = S.fadd x1 y1 in
let t4_s = S.fadd x2 y2 in
let t3_s = S.fmul t3_s t4_s in
let t4_s = S.fadd t0_s t1_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 t3 == t3_s /\
fmont_as_nat h1 t4 == t4_s))
let point_add_1 t0 t1 t2 t3 t4 p q =
let x1, y1, z1 = getx p, gety p, getz p in
let x2, y2, z2 = getx q, gety q, getz q in
fmul t0 x1 x2;
fmul t1 y1 y2;
fmul t2 z1 z2;
fadd t3 x1 y1;
fadd t4 x2 y2;
fmul t3 t3 t4;
fadd t4 t0 t1
inline_for_extraction noextract
val point_add_2 (t1 t2 t3 t4 t5:felem) (p q:point) : Stack unit
(requires fun h ->
live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\ live h t5 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc t1; loc t2; loc t3; loc t4; loc t5 ] /\
eq_or_disjoint p q /\ disjoint p t1 /\ disjoint p t2 /\
disjoint p t3 /\ disjoint p t4 /\ disjoint p t5 /\
disjoint q t1 /\ disjoint q t2 /\ disjoint q t3 /\
disjoint q t4 /\ disjoint q t5 /\
point_inv h p /\ point_inv h q /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc t3 |+| loc t4 |+| loc t5) h0 h1 /\
as_nat h1 t3 < S.prime /\ as_nat h1 t4 < S.prime /\ as_nat h1 t5 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let t3_s = S.fsub t3_s t4_s in
let t4_s = S.fadd y1 z1 in
let t5_s = S.fadd y2 z2 in
let t4_s = S.fmul t4_s t5_s in
let t5_s = S.fadd t1_s t2_s in
let t4_s = S.fsub t4_s t5_s in
fmont_as_nat h1 t3 == t3_s /\ fmont_as_nat h1 t4 == t4_s /\
fmont_as_nat h1 t5 == t5_s))
let point_add_2 t1 t2 t3 t4 t5 p q =
let y1, z1 = gety p, getz p in
let y2, z2 = gety q, getz q in
fsub t3 t3 t4;
fadd t4 y1 z1;
fadd t5 y2 z2;
fmul t4 t4 t5;
fadd t5 t1 t2;
fsub t4 t4 t5
inline_for_extraction noextract
val point_add_3 (x3 y3 t0 t2:felem) (p q:point) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h t0 /\ live h t2 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc t0; loc t2 ] /\
eq_or_disjoint p q /\ disjoint p x3 /\ disjoint p y3 /\
disjoint p t0 /\ disjoint p t2 /\ disjoint q x3 /\
disjoint q y3 /\ disjoint q t0 /\ disjoint q t2 /\
point_inv h p /\ point_inv h q /\
as_nat h t0 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = fmont_as_nat h0 t0 in
let t2_s = fmont_as_nat h0 t2 in
let x3_s = S.fadd x1 z1 in
let y3_s = S.fadd x2 z2 in
let x3_s = S.fmul x3_s y3_s in
let y3_s = S.fadd t0_s t2_s in
let y3_s = S.fsub x3_s y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s))
let point_add_3 x3 y3 t0 t2 p q =
let x1, z1 = getx p, getz p in
let x2, z2 = getx q, getz q in
fadd x3 x1 z1;
fadd y3 x2 z2;
fmul x3 x3 y3;
fadd y3 t0 t2;
fsub y3 x3 y3
inline_for_extraction noextract
val point_add_4 (x3 y3 z3 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t1; loc t2 ] /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\ as_nat h y3 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\ as_nat h1 z3 < S.prime /\
(let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let z3_s = S.fmul S.b_coeff t2_s in
let x3_s = S.fsub y3_s z3_s in
let z3_s = S.fadd x3_s x3_s in
let x3_s = S.fadd x3_s z3_s in
let z3_s = S.fsub t1_s x3_s in
let x3_s = S.fadd t1_s x3_s in
let y3_s = S.fmul S.b_coeff y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\ fmont_as_nat h1 z3 == z3_s))
let point_add_4 x3 y3 z3 t1 t2 =
fmul_by_b_coeff z3 t2;
fsub x3 y3 z3;
fdouble z3 x3;
fadd x3 x3 z3;
fsub z3 t1 x3;
fadd x3 t1 x3;
fmul_by_b_coeff y3 y3
inline_for_extraction noextract
val point_add_5 (x3 y3 z3 t0 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t1 < S.prime /\ as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let t1_s = S.fadd t2_s t2_s in
let t2_s = S.fadd t1_s t2_s in
let y3_s = S.fsub y3_s t2_s in
let y3_s = S.fsub y3_s t0_s in
let t1_s = S.fadd y3_s y3_s in
fmont_as_nat h1 t1 == t1_s /\ fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s))
let point_add_5 x3 y3 z3 t0 t1 t2 =
fdouble t1 t2;
fadd t2 t1 t2;
fsub y3 y3 t2;
fsub y3 y3 t0;
fdouble t1 y3
inline_for_extraction noextract
val point_add_6 (x3 y3 z3 t0 t1 t2 t4:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\ live h t4 /\
LowStar.Monotonic.Buffer.all_disjoint
[ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2; loc t4 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t0 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t4_s = fmont_as_nat h0 t4 in
let y3_s = fmont_as_nat h0 y3 in
let y3_s = S.fadd t1_s y3_s in
let t1_s = S.fadd t0_s t0_s in
let t0_s = S.fadd t1_s t0_s in
let t0_s = S.fsub t0_s t2_s in
let t1_s = S.fmul t4_s y3_s in
let t2_s = S.fmul t0_s y3_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s))
let point_add_6 x3 y3 z3 t0 t1 t2 t4 =
fadd y3 t1 y3;
fdouble t1 t0;
fadd t0 t1 t0;
fsub t0 t0 t2;
fmul t1 t4 y3;
fmul t2 t0 y3
inline_for_extraction noextract
val point_add_7 (x3 y3 z3 t0 t1 t2 t3 t4:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\
LowStar.Monotonic.Buffer.all_disjoint
[ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
as_nat h x3 < S.prime /\ as_nat h z3 < S.prime /\
as_nat h t0 < S.prime /\ as_nat h t1 < S.prime /\
as_nat h t2 < S.prime /\ as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3 |+| loc t1) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
as_nat h1 z3 < S.prime /\ as_nat h1 t1 < S.prime /\
(let x3_s = fmont_as_nat h0 x3 in
let z3_s = fmont_as_nat h0 z3 in
let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let y3_s = S.fmul x3_s z3_s in
let y3_s = S.fadd y3_s t2_s in
let x3_s = S.fmul t3_s x3_s in
let x3_s = S.fsub x3_s t1_s in
let z3_s = S.fmul t4_s z3_s in
let t1_s = S.fmul t3_s t0_s in
let z3_s = S.fadd z3_s t1_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\
fmont_as_nat h1 z3 == z3_s /\ fmont_as_nat h1 t1 == t1_s))
let point_add_7 x3 y3 z3 t0 t1 t2 t3 t4 =
fmul y3 x3 z3;
fadd y3 y3 t2;
fmul x3 t3 x3;
fsub x3 x3 t1;
fmul z3 t4 z3;
fmul t1 t3 t0;
fadd z3 z3 t1
inline_for_extraction noextract
val point_add_noalloc: tmp:lbuffer uint64 24ul -> res:point -> p:point -> q:point -> Stack unit
(requires fun h ->
live h p /\ live h q /\ live h res /\ live h tmp /\
eq_or_disjoint p q /\ disjoint q res /\ disjoint p res /\
disjoint tmp p /\ disjoint tmp q /\ disjoint tmp res /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
point_inv h1 res /\
from_mont_point (as_point_nat h1 res) ==
S.point_add (from_mont_point (as_point_nat h0 p)) (from_mont_point (as_point_nat h0 q)))
let point_add_noalloc tmp res p q =
let x3, y3, z3 = getx res, gety res, getz res in
let t0 = sub tmp 0ul 4ul in
let t1 = sub tmp 4ul 4ul in
let t2 = sub tmp 8ul 4ul in
let t3 = sub tmp 12ul 4ul in
let t4 = sub tmp 16ul 4ul in
let t5 = sub tmp 20ul 4ul in
point_add_1 t0 t1 t2 t3 t4 p q;
point_add_2 t1 t2 t3 t4 t5 p q;
point_add_3 x3 y3 t0 t2 p q;
point_add_4 x3 y3 z3 t1 t2;
point_add_5 x3 y3 z3 t0 t1 t2;
point_add_6 x3 y3 z3 t0 t1 t2 t4;
point_add_7 x3 y3 z3 t0 t1 t2 t3 t4 | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.PointAdd.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Point.point -> p: Hacl.Impl.P256.Point.point -> q: Hacl.Impl.P256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Point.point",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Lib.Buffer.copy",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.P256.PointAdd.point_add_noalloc",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"Lib.Buffer.create",
"Lib.IntTypes.u64",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let point_add res p q =
| push_frame ();
let tmp = create 36ul (u64 0) in
let t0 = sub tmp 0ul 24ul in
let t1 = sub tmp 24ul 12ul in
point_add_noalloc t0 t1 p q;
copy res t1;
pop_frame () | false |
Pulse.Extract.Main.fst | Pulse.Extract.Main.term_as_mlty | val term_as_mlty (g: env) (t: term) : T.Tac mlty | val term_as_mlty (g: env) (t: term) : T.Tac mlty | let term_as_mlty (g:env) (t:term)
: T.Tac mlty
= let t = Elab.elab_term t in
term_as_mlty (uenv_of_env g) t | {
"file_name": "lib/steel/pulse/Pulse.Extract.Main.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 34,
"end_line": 67,
"start_col": 0,
"start_line": 64
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Extract.Main
open Pulse.Syntax.Base
open Pulse.Syntax.Pure
open Pulse.Extract.CompilerLib
open Pulse.Syntax.Printer
open FStar.List.Tot
module L = FStar.List.Tot
module R = FStar.Reflection
module RT = FStar.Reflection.Typing
module T = FStar.Tactics.V2
module RB = Pulse.Readback
module Elab = Pulse.Elaborate.Pure
module E = Pulse.Typing.Env
module LN = Pulse.Syntax.Naming
module RU = Pulse.RuntimeUtils
module ECL = Pulse.Extract.CompilerLib
exception Extraction_failure of string
noeq
type env = {
uenv_inner: uenv;
coreenv: Pulse.Typing.Env.env
}
let name = ppname & nat
let topenv_of_env (g:env) = E.fstar_env g.coreenv
let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv
let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g)
let debug (g:env) (f: unit -> T.Tac string)
: T.Tac unit
= if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction"
then T.print (f())
let term_as_mlexpr (g:env) (t:term)
: T.Tac mlexpr
= let t = Elab.elab_term t in
let uenv = uenv_of_env g in
let t = normalize_for_extraction uenv t in
let mlt, _, _ = term_as_mlexpr uenv t in
mlt | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Pure.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Naming.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Readback.fsti.checked",
"Pulse.Extract.CompilerLib.fsti.checked",
"Pulse.Elaborate.Pure.fst.checked",
"Pulse.Checker.Match.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Reflection.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Pulse.Extract.Main.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": "ECL"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Naming",
"short_module": "LN"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Pulse.Elaborate.Pure",
"short_module": "Elab"
},
{
"abbrev": true,
"full_module": "Pulse.Readback",
"short_module": "RB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Reflection",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": 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 | g: Pulse.Extract.Main.env -> t: Pulse.Syntax.Base.term
-> FStar.Tactics.Effect.Tac Pulse.Extract.CompilerLib.mlty | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Extract.Main.env",
"Pulse.Syntax.Base.term",
"Pulse.Extract.CompilerLib.term_as_mlty",
"Pulse.Extract.Main.uenv_of_env",
"Pulse.Extract.CompilerLib.mlty",
"FStar.Stubs.Reflection.Types.term",
"Pulse.Elaborate.Pure.elab_term"
] | [] | false | true | false | false | false | let term_as_mlty (g: env) (t: term) : T.Tac mlty =
| let t = Elab.elab_term t in
term_as_mlty (uenv_of_env g) t | false |
Pulse.Extract.Main.fst | Pulse.Extract.Main.tcenv_of_env | val tcenv_of_env : g: Pulse.Extract.Main.env -> FStar.Stubs.Reflection.Types.env | let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv | {
"file_name": "lib/steel/pulse/Pulse.Extract.Main.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 58,
"end_line": 47,
"start_col": 0,
"start_line": 47
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Extract.Main
open Pulse.Syntax.Base
open Pulse.Syntax.Pure
open Pulse.Extract.CompilerLib
open Pulse.Syntax.Printer
open FStar.List.Tot
module L = FStar.List.Tot
module R = FStar.Reflection
module RT = FStar.Reflection.Typing
module T = FStar.Tactics.V2
module RB = Pulse.Readback
module Elab = Pulse.Elaborate.Pure
module E = Pulse.Typing.Env
module LN = Pulse.Syntax.Naming
module RU = Pulse.RuntimeUtils
module ECL = Pulse.Extract.CompilerLib
exception Extraction_failure of string
noeq
type env = {
uenv_inner: uenv;
coreenv: Pulse.Typing.Env.env
}
let name = ppname & nat | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Pure.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Naming.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Readback.fsti.checked",
"Pulse.Extract.CompilerLib.fsti.checked",
"Pulse.Elaborate.Pure.fst.checked",
"Pulse.Checker.Match.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Reflection.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Pulse.Extract.Main.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": "ECL"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Naming",
"short_module": "LN"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Pulse.Elaborate.Pure",
"short_module": "Elab"
},
{
"abbrev": true,
"full_module": "Pulse.Readback",
"short_module": "RB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Reflection",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": 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 | g: Pulse.Extract.Main.env -> FStar.Stubs.Reflection.Types.env | Prims.Tot | [
"total"
] | [] | [
"Pulse.Extract.Main.env",
"Pulse.Typing.elab_env",
"Pulse.Extract.Main.__proj__Mkenv__item__coreenv",
"FStar.Stubs.Reflection.Types.env"
] | [] | false | false | false | true | false | let tcenv_of_env (g: env) =
| Pulse.Typing.elab_env g.coreenv | false |
|
Pulse.Extract.Main.fst | Pulse.Extract.Main.extend_env_pat | val extend_env_pat : g: Pulse.Extract.Main.env -> p: Pulse.Syntax.Base.pattern
-> FStar.Tactics.Effect.Tac
((Pulse.Extract.Main.env * Pulse.Extract.CompilerLib.mlpattern) *
Prims.list Pulse.Typing.Env.binding) | let extend_env_pat g p =
let g, pats, bs = extend_env_pat_core g p in
match pats with
| [p] -> g, p, bs
| _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") | {
"file_name": "lib/steel/pulse/Pulse.Extract.Main.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 72,
"end_line": 132,
"start_col": 0,
"start_line": 128
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Extract.Main
open Pulse.Syntax.Base
open Pulse.Syntax.Pure
open Pulse.Extract.CompilerLib
open Pulse.Syntax.Printer
open FStar.List.Tot
module L = FStar.List.Tot
module R = FStar.Reflection
module RT = FStar.Reflection.Typing
module T = FStar.Tactics.V2
module RB = Pulse.Readback
module Elab = Pulse.Elaborate.Pure
module E = Pulse.Typing.Env
module LN = Pulse.Syntax.Naming
module RU = Pulse.RuntimeUtils
module ECL = Pulse.Extract.CompilerLib
exception Extraction_failure of string
noeq
type env = {
uenv_inner: uenv;
coreenv: Pulse.Typing.Env.env
}
let name = ppname & nat
let topenv_of_env (g:env) = E.fstar_env g.coreenv
let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv
let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g)
let debug (g:env) (f: unit -> T.Tac string)
: T.Tac unit
= if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction"
then T.print (f())
let term_as_mlexpr (g:env) (t:term)
: T.Tac mlexpr
= let t = Elab.elab_term t in
let uenv = uenv_of_env g in
let t = normalize_for_extraction uenv t in
let mlt, _, _ = term_as_mlexpr uenv t in
mlt
let term_as_mlty (g:env) (t:term)
: T.Tac mlty
= let t = Elab.elab_term t in
term_as_mlty (uenv_of_env g) t
let extend_env (g:env) (b:binder)
: T.Tac (env & mlident & mlty & name)
= let mlty = term_as_mlty g b.binder_ty in
let x = E.fresh g.coreenv in
let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in
debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n"
(binder_to_string b)
(term_to_string b.binder_ty));
let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in
{ uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x)
let rec name_as_mlpath (x:T.name)
: T.Tac mlpath
= match x with
| [] -> T.fail "Unexpected empty name"
| [x] -> [], x
| x :: xs ->
let xs, x = name_as_mlpath xs in
x :: xs, x
module R = FStar.Reflection.V2
let extract_constant (g:env) (c:T.vconst)
: T.Tac mlconstant
= let e = T.pack_ln (R.Tv_Const c) in
let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in
match mlconstant_of_mlexpr mle with
| None -> T.raise (Extraction_failure "Failed to extract constant")
| Some c -> c
let rec extend_env_pat_core (g:env) (p:pattern)
: T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding)
= match p with
| Pat_Dot_Term _ -> g, [], []
| Pat_Var pp sort ->
let x = E.fresh g.coreenv in
let pp = mk_ppname pp FStar.Range.range_0 in
let ty = T.unseal sort in
assume (not_tv_unknown ty);
let ty = tm_fstar ty (T.range_of_term ty) in
debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty));
let coreenv = E.push_binding g.coreenv x pp ty in
let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in
{ uenv_inner; coreenv },
[ mlp_var mlident ],
[ (x, tm_unknown) ]
| Pat_Cons f pats ->
let g, pats, bindings =
T.fold_left
(fun (g, pats, bindings) (p, _) ->
let g, pats', bindings' = extend_env_pat_core g p in
g, pats @ pats', bindings@bindings')
(g, [], [])
pats
in
g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings
| Pat_Constant c ->
let c = extract_constant g c in | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Pure.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Naming.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Readback.fsti.checked",
"Pulse.Extract.CompilerLib.fsti.checked",
"Pulse.Elaborate.Pure.fst.checked",
"Pulse.Checker.Match.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Reflection.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Pulse.Extract.Main.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": "ECL"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Naming",
"short_module": "LN"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Pulse.Elaborate.Pure",
"short_module": "Elab"
},
{
"abbrev": true,
"full_module": "Pulse.Readback",
"short_module": "RB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Reflection",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": 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 | g: Pulse.Extract.Main.env -> p: Pulse.Syntax.Base.pattern
-> FStar.Tactics.Effect.Tac
((Pulse.Extract.Main.env * Pulse.Extract.CompilerLib.mlpattern) *
Prims.list Pulse.Typing.Env.binding) | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Extract.Main.env",
"Pulse.Syntax.Base.pattern",
"Prims.list",
"Pulse.Extract.CompilerLib.mlpattern",
"Pulse.Typing.Env.binding",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.tuple3",
"FStar.Tactics.Effect.raise",
"Pulse.Extract.Main.Extraction_failure",
"Pulse.Extract.Main.extend_env_pat_core"
] | [] | false | true | false | false | false | let extend_env_pat g p =
| let g, pats, bs = extend_env_pat_core g p in
match pats with
| [p] -> g, p, bs
| _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") | false |
|
Pulse.Extract.Main.fst | Pulse.Extract.Main.is_erasable | val is_erasable (p: st_term) : T.Tac bool | val is_erasable (p: st_term) : T.Tac bool | let is_erasable (p:st_term) : T.Tac bool =
let tag = T.unseal p.effect_tag in
match tag with
| Some STT_Ghost -> true
| _ -> false | {
"file_name": "lib/steel/pulse/Pulse.Extract.Main.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 14,
"end_line": 139,
"start_col": 0,
"start_line": 135
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Extract.Main
open Pulse.Syntax.Base
open Pulse.Syntax.Pure
open Pulse.Extract.CompilerLib
open Pulse.Syntax.Printer
open FStar.List.Tot
module L = FStar.List.Tot
module R = FStar.Reflection
module RT = FStar.Reflection.Typing
module T = FStar.Tactics.V2
module RB = Pulse.Readback
module Elab = Pulse.Elaborate.Pure
module E = Pulse.Typing.Env
module LN = Pulse.Syntax.Naming
module RU = Pulse.RuntimeUtils
module ECL = Pulse.Extract.CompilerLib
exception Extraction_failure of string
noeq
type env = {
uenv_inner: uenv;
coreenv: Pulse.Typing.Env.env
}
let name = ppname & nat
let topenv_of_env (g:env) = E.fstar_env g.coreenv
let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv
let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g)
let debug (g:env) (f: unit -> T.Tac string)
: T.Tac unit
= if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction"
then T.print (f())
let term_as_mlexpr (g:env) (t:term)
: T.Tac mlexpr
= let t = Elab.elab_term t in
let uenv = uenv_of_env g in
let t = normalize_for_extraction uenv t in
let mlt, _, _ = term_as_mlexpr uenv t in
mlt
let term_as_mlty (g:env) (t:term)
: T.Tac mlty
= let t = Elab.elab_term t in
term_as_mlty (uenv_of_env g) t
let extend_env (g:env) (b:binder)
: T.Tac (env & mlident & mlty & name)
= let mlty = term_as_mlty g b.binder_ty in
let x = E.fresh g.coreenv in
let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in
debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n"
(binder_to_string b)
(term_to_string b.binder_ty));
let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in
{ uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x)
let rec name_as_mlpath (x:T.name)
: T.Tac mlpath
= match x with
| [] -> T.fail "Unexpected empty name"
| [x] -> [], x
| x :: xs ->
let xs, x = name_as_mlpath xs in
x :: xs, x
module R = FStar.Reflection.V2
let extract_constant (g:env) (c:T.vconst)
: T.Tac mlconstant
= let e = T.pack_ln (R.Tv_Const c) in
let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in
match mlconstant_of_mlexpr mle with
| None -> T.raise (Extraction_failure "Failed to extract constant")
| Some c -> c
let rec extend_env_pat_core (g:env) (p:pattern)
: T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding)
= match p with
| Pat_Dot_Term _ -> g, [], []
| Pat_Var pp sort ->
let x = E.fresh g.coreenv in
let pp = mk_ppname pp FStar.Range.range_0 in
let ty = T.unseal sort in
assume (not_tv_unknown ty);
let ty = tm_fstar ty (T.range_of_term ty) in
debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty));
let coreenv = E.push_binding g.coreenv x pp ty in
let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in
{ uenv_inner; coreenv },
[ mlp_var mlident ],
[ (x, tm_unknown) ]
| Pat_Cons f pats ->
let g, pats, bindings =
T.fold_left
(fun (g, pats, bindings) (p, _) ->
let g, pats', bindings' = extend_env_pat_core g p in
g, pats @ pats', bindings@bindings')
(g, [], [])
pats
in
g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings
| Pat_Constant c ->
let c = extract_constant g c in
g, [mlp_const c], []
let extend_env_pat g p =
let g, pats, bs = extend_env_pat_core g p in
match pats with
| [p] -> g, p, bs
| _ -> T.raise (Extraction_failure "Unexpected extraction of pattern") | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Pure.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Naming.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Readback.fsti.checked",
"Pulse.Extract.CompilerLib.fsti.checked",
"Pulse.Elaborate.Pure.fst.checked",
"Pulse.Checker.Match.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Reflection.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Pulse.Extract.Main.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": "ECL"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Naming",
"short_module": "LN"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Pulse.Elaborate.Pure",
"short_module": "Elab"
},
{
"abbrev": true,
"full_module": "Pulse.Readback",
"short_module": "RB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Reflection",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": 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 | p: Pulse.Syntax.Base.st_term -> FStar.Tactics.Effect.Tac Prims.bool | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Syntax.Base.st_term",
"FStar.Pervasives.Native.option",
"Pulse.Syntax.Base.ctag",
"Prims.bool",
"FStar.Tactics.Unseal.unseal",
"Pulse.Syntax.Base.__proj__Mkst_term__item__effect_tag"
] | [] | false | true | false | false | false | let is_erasable (p: st_term) : T.Tac bool =
| let tag = T.unseal p.effect_tag in
match tag with
| Some STT_Ghost -> true
| _ -> false | false |
Pulse.Extract.Main.fst | Pulse.Extract.Main.fresh | val fresh : g: Pulse.Extract.Main.env
-> v: Pulse.Syntax.Base.var{~(FStar.Set.mem v (Pulse.Typing.Env.dom (Mkenv?.coreenv g)))} | let fresh (g:env) = Pulse.Typing.fresh g.coreenv | {
"file_name": "lib/steel/pulse/Pulse.Extract.Main.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 48,
"end_line": 308,
"start_col": 0,
"start_line": 308
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Extract.Main
open Pulse.Syntax.Base
open Pulse.Syntax.Pure
open Pulse.Extract.CompilerLib
open Pulse.Syntax.Printer
open FStar.List.Tot
module L = FStar.List.Tot
module R = FStar.Reflection
module RT = FStar.Reflection.Typing
module T = FStar.Tactics.V2
module RB = Pulse.Readback
module Elab = Pulse.Elaborate.Pure
module E = Pulse.Typing.Env
module LN = Pulse.Syntax.Naming
module RU = Pulse.RuntimeUtils
module ECL = Pulse.Extract.CompilerLib
exception Extraction_failure of string
noeq
type env = {
uenv_inner: uenv;
coreenv: Pulse.Typing.Env.env
}
let name = ppname & nat
let topenv_of_env (g:env) = E.fstar_env g.coreenv
let tcenv_of_env (g:env) = Pulse.Typing.elab_env g.coreenv
let uenv_of_env (g:env) = set_tcenv g.uenv_inner (tcenv_of_env g)
let debug (g:env) (f: unit -> T.Tac string)
: T.Tac unit
= if RU.debug_at_level (E.fstar_env g.coreenv) "pulse_extraction"
then T.print (f())
let term_as_mlexpr (g:env) (t:term)
: T.Tac mlexpr
= let t = Elab.elab_term t in
let uenv = uenv_of_env g in
let t = normalize_for_extraction uenv t in
let mlt, _, _ = term_as_mlexpr uenv t in
mlt
let term_as_mlty (g:env) (t:term)
: T.Tac mlty
= let t = Elab.elab_term t in
term_as_mlty (uenv_of_env g) t
let extend_env (g:env) (b:binder)
: T.Tac (env & mlident & mlty & name)
= let mlty = term_as_mlty g b.binder_ty in
let x = E.fresh g.coreenv in
let coreenv = E.push_binding g.coreenv x b.binder_ppname b.binder_ty in
debug g (fun _ -> Printf.sprintf "Extending environment with %s : %s\n"
(binder_to_string b)
(term_to_string b.binder_ty));
let uenv_inner, mlident = extend_bv g.uenv_inner b.binder_ppname x mlty in
{ uenv_inner; coreenv }, mlident, mlty, (b.binder_ppname, x)
let rec name_as_mlpath (x:T.name)
: T.Tac mlpath
= match x with
| [] -> T.fail "Unexpected empty name"
| [x] -> [], x
| x :: xs ->
let xs, x = name_as_mlpath xs in
x :: xs, x
module R = FStar.Reflection.V2
let extract_constant (g:env) (c:T.vconst)
: T.Tac mlconstant
= let e = T.pack_ln (R.Tv_Const c) in
let mle, _, _ = CompilerLib.term_as_mlexpr (uenv_of_env g) e in
match mlconstant_of_mlexpr mle with
| None -> T.raise (Extraction_failure "Failed to extract constant")
| Some c -> c
let rec extend_env_pat_core (g:env) (p:pattern)
: T.Tac (env & list mlpattern & list Pulse.Typing.Env.binding)
= match p with
| Pat_Dot_Term _ -> g, [], []
| Pat_Var pp sort ->
let x = E.fresh g.coreenv in
let pp = mk_ppname pp FStar.Range.range_0 in
let ty = T.unseal sort in
assume (not_tv_unknown ty);
let ty = tm_fstar ty (T.range_of_term ty) in
debug g (fun _ -> Printf.sprintf "Pushing pat_var %s : %s\n" (T.unseal pp.name) (term_to_string ty));
let coreenv = E.push_binding g.coreenv x pp ty in
let uenv_inner, mlident = extend_bv g.uenv_inner pp x mlty_top in
{ uenv_inner; coreenv },
[ mlp_var mlident ],
[ (x, tm_unknown) ]
| Pat_Cons f pats ->
let g, pats, bindings =
T.fold_left
(fun (g, pats, bindings) (p, _) ->
let g, pats', bindings' = extend_env_pat_core g p in
g, pats @ pats', bindings@bindings')
(g, [], [])
pats
in
g, [mlp_constructor (name_as_mlpath f.fv_name) pats], bindings
| Pat_Constant c ->
let c = extract_constant g c in
g, [mlp_const c], []
let extend_env_pat g p =
let g, pats, bs = extend_env_pat_core g p in
match pats with
| [p] -> g, p, bs
| _ -> T.raise (Extraction_failure "Unexpected extraction of pattern")
let unit_val : term = tm_fstar Pulse.Reflection.Util.unit_tm Range.range_0
let is_erasable (p:st_term) : T.Tac bool =
let tag = T.unseal p.effect_tag in
match tag with
| Some STT_Ghost -> true
| _ -> false
let head_and_args (t:term)
: option (R.term & list R.argv) =
match t.t with
| Tm_FStar t0 -> Some (R.collect_app_ln t0)
| _ -> None
let term_eq_string (s:string) (t:R.term) : bool =
match R.inspect_ln t with
| R.Tv_Const (R.C_String s') -> s=s'
| _ -> false
let maybe_unfold_head (g:env) (head:R.term)
: T.Tac (option (either st_term R.term))
= debug g (fun _ -> Printf.sprintf "Maybe unfolding head %s\n" (T.term_to_string head));
match R.inspect_ln head with
| R.Tv_FVar f -> (
let name = R.inspect_fv f in
match R.lookup_typ (topenv_of_env g) name with
| None -> None
| Some se ->
let attrs = R.sigelt_attrs se in
let quals = R.sigelt_quals se in
if List.Tot.existsb (term_eq_string "inline") attrs
|| List.Tot.existsb (function | R.Inline_for_extraction -> true | _ -> false) quals
then match sigelt_extension_data se with
| Some se ->
debug g (fun _ -> Printf.sprintf "Unfolded head %s\n" (T.term_to_string head));
debug g (fun _ -> Printf.sprintf "to %s\n" (st_term_to_string se));
Some (Inl se)
| None -> (
match T.inspect_sigelt se with
| T.Sg_Let { isrec=false; lbs = [ { lb_us=[]; lb_def }] } ->
Some (Inr lb_def)
| _ -> None
)
else None
)
| R.Tv_UInst f _ ->
//No universe-polymorphic inlining ... yet
None
| _ -> None
let rec st_term_abs_take_n_args (n_args:nat) (t:st_term)
: res:(st_term & nat){snd res <= n_args}
= if n_args = 0 then t, 0
else (
match t.term with
| Tm_Abs { body } -> st_term_abs_take_n_args (n_args - 1) body
| _ -> (t, n_args)
)
let rec term_abs_take_n_args (n_args:nat) (t:R.term)
: res:(R.term & nat){snd res <= n_args}
= if n_args = 0 then t, 0
else (
match R.inspect_ln t with
| R.Tv_Abs _ body -> term_abs_take_n_args (n_args - 1) body
| _ -> (t, n_args)
)
let abs_take_n_args (n_args:nat) (t:either st_term R.term)
: T.Tac (res:(either st_term R.term & nat){snd res <= n_args})
= match t with
| Inl t ->
let t, n_args = st_term_abs_take_n_args n_args t in
Inl t, n_args
| Inr t ->
let t, n_args = term_abs_take_n_args n_args t in
Inr t, n_args
let rec unascribe (t:R.term) : T.Tac R.term =
match R.inspect_ln t with
| R.Tv_AscribedT e _ _ _ -> unascribe e
| R.Tv_AscribedC e _ _ _ -> unascribe e
| _ -> t
let maybe_inline (g:env) (head:term) (arg:term) :T.Tac (option st_term) =
debug g (fun _ -> Printf.sprintf "Considering inlining %s\n"
(term_to_string head));
match head_and_args head with
| None -> None
| Some (head, args) ->
debug g (fun _ -> Printf.sprintf "head=%s with %d args\n"
(T.term_to_string head)
(List.length args));
match maybe_unfold_head g head with
| None ->
debug g (fun _ -> Printf.sprintf "No unfolding of %s\n"
(T.term_to_string head));
None
| Some def ->
// debug g (fun _ -> Printf.sprintf "Unfolded %s to body %s\n"
// (T.term_to_string head)
// (st_term_to_string body));
let as_term (a:R.term) = assume (not_tv_unknown a); tm_fstar a Range.range_0 in
let all_args : list (term & option qualifier) =
L.map #R.argv
(fun (t, q) ->
let t = as_term t in
let qual = if R.Q_Implicit? q then Some Implicit else None in
t, qual)
args
@ [arg, None]
in
let n_args = L.length all_args in
let body, remaining_args = abs_take_n_args n_args def in
let args, rest = L.splitAt (n_args - remaining_args) all_args in
let _, subst =
L.fold_right
(fun arg (i, subst) ->
i + 1,
LN.DT i (fst arg)::subst)
args
(0, [])
in
match body with
| Inl body -> (
let applied_body = LN.subst_st_term body subst in
match rest with
| [] ->
Some applied_body
| _ ->
T.fail (Printf.sprintf
"Partial or over application of inlined Pulse definition is not yet supported\n\
%s has %d arguments, but %s were left unapplied"
(T.term_to_string head)
(L.length args)
(String.concat ", " (T.map (fun x -> term_to_string (fst x)) rest))
)
)
| Inr body ->
assume (not_tv_unknown body);
let applied_body = unascribe (LN.subst_host_term body subst) in
let mk_st_app (head:R.term) (arg:term) (arg_qual:option qualifier) =
assume (not_tv_unknown head);
let head = tm_fstar head (T.range_of_term head) in
let tm = Tm_STApp { head; arg_qual; arg } in
Some { term = tm; range=FStar.Range.range_0; effect_tag=default_effect_hint }
in
match rest with
| [] -> (
match R.inspect_ln applied_body with
| R.Tv_App head (arg, aqual) ->
assume (not_tv_unknown arg);
let arg = tm_fstar arg (T.range_of_term arg) in
let arg_qual = if R.Q_Implicit? aqual then Some Implicit else None in
mk_st_app head arg arg_qual
| _ ->
T.fail
(Printf.sprintf "Cannot inline F* definitions of stt terms whose body is not an application; got %s"
(T.term_to_string applied_body))
)
| rest ->
FStar.List.Tot.lemma_splitAt_snd_length (L.length rest - 1) rest;
let rest, [last] = L.splitAt (L.length rest - 1) rest in
let head =
L.fold_left
(fun head (tm, qual) ->
R.pack_ln (
R.Tv_App head (Pulse.Elaborate.Pure.elab_term tm, (if Some? qual then R.Q_Implicit else R.Q_Explicit))
))
applied_body
rest
in
mk_st_app head (fst last) (snd last) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Pure.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.Naming.fsti.checked",
"Pulse.Syntax.Base.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Readback.fsti.checked",
"Pulse.Extract.CompilerLib.fsti.checked",
"Pulse.Elaborate.Pure.fst.checked",
"Pulse.Checker.Match.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Reflection.fst.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Pulse.Extract.Main.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": "ECL"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Naming",
"short_module": "LN"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Env",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Pulse.Elaborate.Pure",
"short_module": "Elab"
},
{
"abbrev": true,
"full_module": "Pulse.Readback",
"short_module": "RB"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Reflection",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Printer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract.CompilerLib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Extract",
"short_module": null
},
{
"abbrev": 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 | g: Pulse.Extract.Main.env
-> v: Pulse.Syntax.Base.var{~(FStar.Set.mem v (Pulse.Typing.Env.dom (Mkenv?.coreenv g)))} | Prims.Tot | [
"total"
] | [] | [
"Pulse.Extract.Main.env",
"Pulse.Typing.Env.fresh",
"Pulse.Extract.Main.__proj__Mkenv__item__coreenv",
"Pulse.Syntax.Base.var",
"Prims.l_not",
"Prims.b2t",
"FStar.Set.mem",
"Pulse.Typing.Env.dom"
] | [] | false | false | false | false | false | let fresh (g: env) =
| Pulse.Typing.fresh g.coreenv | false |