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.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.nat32 | val nat32 : Type0 | let nat32 = Vale.Def.Words_s.nat32 | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 12,
"start_col": 7,
"start_line": 12
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8 | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Words_s.nat32"
] | [] | false | false | false | true | true | let nat32 =
| Vale.Def.Words_s.nat32 | false |
|
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.nat64 | val nat64 : Type0 | let nat64 = Vale.Def.Words_s.nat64 | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 17,
"start_col": 7,
"start_line": 17
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} = | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Words_s.nat64"
] | [] | false | false | false | true | true | let nat64 =
| Vale.Def.Words_s.nat64 | false |
|
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.quad32 | val quad32 : Prims.eqtype | let quad32 = Vale.Def.Types_s.quad32 | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 20,
"start_col": 7,
"start_line": 20
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i
unfold let nat64 = Vale.Def.Words_s.nat64
let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} = | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.quad32"
] | [] | false | false | false | true | false | let quad32 =
| Vale.Def.Types_s.quad32 | false |
|
Hacl.Impl.Frodo.Pack.fst | Hacl.Impl.Frodo.Pack.frodo_unpack8 | val frodo_unpack8:
d:size_t{v d <= 16}
-> b:lbytes d
-> res:lbuffer uint16 8ul
-> Stack unit
(requires fun h0 -> live h0 b /\ live h0 res)
(ensures fun h0 _ h1 ->
modifies1 res h0 h1 /\
Seq.equal (as_seq h1 res) (S.frodo_unpack8 (v d) (as_seq h0 b))) | val frodo_unpack8:
d:size_t{v d <= 16}
-> b:lbytes d
-> res:lbuffer uint16 8ul
-> Stack unit
(requires fun h0 -> live h0 b /\ live h0 res)
(ensures fun h0 _ h1 ->
modifies1 res h0 h1 /\
Seq.equal (as_seq h1 res) (S.frodo_unpack8 (v d) (as_seq h0 b))) | let frodo_unpack8 d b res =
let h0 = ST.get() in
push_frame();
let maskd = to_u16 (u32 1 <<. d) -. u16 1 in
let src = create (size 16) (u8 0) in
update_sub src (size 16 -! d) d b;
let templong = uint_from_bytes_be #U128 #SEC src in
res.(size 0) <- to_u16 (templong >>. (size 7 *! d)) &. maskd;
res.(size 1) <- to_u16 (templong >>. (size 6 *! d)) &. maskd;
res.(size 2) <- to_u16 (templong >>. (size 5 *! d)) &. maskd;
res.(size 3) <- to_u16 (templong >>. (size 4 *! d)) &. maskd;
res.(size 4) <- to_u16 (templong >>. (size 3 *! d)) &. maskd;
res.(size 5) <- to_u16 (templong >>. (size 2 *! d)) &. maskd;
res.(size 6) <- to_u16 (templong >>. (size 1 *! d)) &. maskd;
res.(size 7) <- to_u16 (templong >>. (size 0 *! d)) &. maskd;
pop_frame() | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Pack.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 130,
"start_col": 0,
"start_line": 115
} | module Hacl.Impl.Frodo.Pack
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
module Seq = Lib.Sequence
module S = Spec.Frodo.Pack
#reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -Spec +Spec.Frodo.Pack +Spec.Matrix'"
val lemma_split: #a:Type -> #len:size_nat -> s:Seq.lseq a len -> i:size_nat{i <= len} ->
Lemma (s == Seq.(Seq.sub s 0 i @| Seq.sub s i (len - i)))
let lemma_split #a #len s i =
FStar.Seq.lemma_split s i
/// Pack
inline_for_extraction noextract
val frodo_pack8:
d:size_t{v d <= 16}
-> a:lbuffer uint16 8ul
-> res:lbytes d
-> Stack unit
(requires fun h0 -> live h0 a /\ live h0 res /\ disjoint a res)
(ensures fun h0 _ h1 ->
modifies1 res h0 h1 /\
as_seq h1 res == S.frodo_pack8 (v d) (as_seq h0 a))
let frodo_pack8 d a res =
let h0 = ST.get() in
push_frame();
let maskd = to_u16 (u32 1 <<. d) -. u16 1 in
let v16 = create (size 16) (u8 0) in
let a0 = index a (size 0) &. maskd in
let a1 = index a (size 1) &. maskd in
let a2 = index a (size 2) &. maskd in
let a3 = index a (size 3) &. maskd in
let a4 = index a (size 4) &. maskd in
let a5 = index a (size 5) &. maskd in
let a6 = index a (size 6) &. maskd in
let a7 = index a (size 7) &. maskd in
let templong =
to_u128 a0 <<. (size 7 *! d)
|. to_u128 a1 <<. (size 6 *! d)
|. to_u128 a2 <<. (size 5 *! d)
|. to_u128 a3 <<. (size 4 *! d)
|. to_u128 a4 <<. (size 3 *! d)
|. to_u128 a5 <<. (size 2 *! d)
|. to_u128 a6 <<. (size 1 *! d)
|. to_u128 a7 <<. (size 0 *! d)
in
uint_to_bytes_be v16 templong;
let src = sub v16 (size 16 -! d) d in // Skips the 1st byte when d = 15
copy res src;
pop_frame()
val frodo_pack:
#n1:size_t
-> #n2:size_t{v n1 * v n2 <= max_size_t /\ (v n1 * v n2) % 8 = 0}
-> d:size_t{v d * ((v n1 * v n2) / 8) <= max_size_t /\ v d <= 16}
-> a:matrix_t n1 n2
-> res:lbytes (d *! ((n1 *! n2) /. size 8))
-> Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint a res)
(ensures fun h0 _ h1 ->
modifies1 res h0 h1 /\
as_seq h1 res == S.frodo_pack (v d) (as_matrix h0 a))
#push-options "--z3rlimit 400"
[@"c_inline"]
let frodo_pack #n1 #n2 d a res =
let n = (n1 *! n2) /. size 8 in
let a_spec = S.frodo_pack_state #(v n1) #(v n2) (v d) in
[@ inline_let]
let refl h (i:size_nat{i <= v n}) = Seq.sub (as_seq h res) 0 (v d * i) in
let footprint (i:size_nat{i <= v n}) = loc res in
[@ inline_let]
let spec h0 = S.frodo_pack_inner #(v n1) #(v n2) (v d) (as_seq h0 a) in
let h0 = ST.get() in
assert (Seq.equal (refl h0 0) (Seq.create 0 (u8 0)));
loop h0 n a_spec refl footprint spec
(fun i ->
FStar.Math.Lemmas.lemma_mult_le_left (v d) (v i + 1) (v n);
assert (v (d *! i +! d) <= v (d *! ((n1 *! n2) /. size 8)));
Loops.unfold_repeat_gen (v n) a_spec (spec h0) (refl h0 0) (v i);
let a = sub a (size 8 *! i) (size 8) in
let r = sub res (d *! i) d in
frodo_pack8 d a r;
let h = ST.get() in
lemma_split (refl h (v i + 1)) (v d * v i)
)
#pop-options
/// Unpack
inline_for_extraction noextract
[@"opaque_to_smt"]
val frodo_unpack8:
d:size_t{v d <= 16}
-> b:lbytes d
-> res:lbuffer uint16 8ul
-> Stack unit
(requires fun h0 -> live h0 b /\ live h0 res)
(ensures fun h0 _ h1 ->
modifies1 res h0 h1 /\ | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Pack.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Pack.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Pack",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"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.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
d: Lib.IntTypes.size_t{Lib.IntTypes.v d <= 16} ->
b: Hacl.Impl.Matrix.lbytes d ->
res: Lib.Buffer.lbuffer Lib.IntTypes.uint16 8ul
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Matrix.lbytes",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint16",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.size",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.to_u16",
"Lib.IntTypes.U128",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.int_t",
"Lib.ByteBuffer.uint_from_bytes_be",
"Lib.IntTypes.uint_t",
"Lib.Buffer.update_sub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Subtraction_Bang",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.mk_int",
"Lib.Buffer.create",
"Lib.IntTypes.u8",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.u32",
"Lib.IntTypes.u16",
"FStar.HyperStack.ST.push_frame",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let frodo_unpack8 d b res =
| let h0 = ST.get () in
push_frame ();
let maskd = to_u16 (u32 1 <<. d) -. u16 1 in
let src = create (size 16) (u8 0) in
update_sub src (size 16 -! d) d b;
let templong = uint_from_bytes_be #U128 #SEC src in
res.(size 0) <- to_u16 (templong >>. (size 7 *! d)) &. maskd;
res.(size 1) <- to_u16 (templong >>. (size 6 *! d)) &. maskd;
res.(size 2) <- to_u16 (templong >>. (size 5 *! d)) &. maskd;
res.(size 3) <- to_u16 (templong >>. (size 4 *! d)) &. maskd;
res.(size 4) <- to_u16 (templong >>. (size 3 *! d)) &. maskd;
res.(size 5) <- to_u16 (templong >>. (size 2 *! d)) &. maskd;
res.(size 6) <- to_u16 (templong >>. (size 1 *! d)) &. maskd;
res.(size 7) <- to_u16 (templong >>. (size 0 *! d)) &. maskd;
pop_frame () | false |
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.vecs_t | val vecs_t : Type0 | let vecs_t = FStar.FunctionalExtensionality.restricted_t vec (fun _ -> quad32) | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 78,
"end_line": 41,
"start_col": 0,
"start_line": 41
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i
unfold let nat64 = Vale.Def.Words_s.nat64
let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_64 i
unfold let quad32 = Vale.Def.Types_s.quad32
type reg = i:int{0 <= i /\ i < 32}
type vec = i:int{0 <= i /\ i < 32}
// Immediate operand of logical compare, and, or, and xor instructions
type imm16 = i:int{0 <= i && i <= 65535}
// Immediate operand of compare, add (with signed immediate) instructions
type simm16 = i:int{-32768 <= i && i <= 32767}
// Immediate operand of sub (with negative signed immediate) instruction
type nsimm16 = i:int{-32767 <= i && i <= 32768}
// Immediate operand of rotate, shift, and clear for 64-bit instructions
type bits64 = i:int{0 <= i && i < 64}
// Immediate operand of rotate, shift, and clear for 32-bit instructions
type bits32 = i:int{0 <= i && i < 32}
// Immediate operand of vector shift left double by octet
type quad32bytes = i:int{0 <= i && i < 16}
// Immediate operand of vector splat
type sim = i:int{-16 <= i && i < 15} | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.FunctionalExtensionality.restricted_t",
"Vale.PPC64LE.Machine_s.vec",
"Vale.PPC64LE.Machine_s.quad32"
] | [] | false | false | false | true | true | let vecs_t =
| FStar.FunctionalExtensionality.restricted_t vec (fun _ -> quad32) | false |
|
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.regs_t | val regs_t : Type0 | let regs_t = FStar.FunctionalExtensionality.restricted_t reg (fun _ -> nat64) | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 77,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i
unfold let nat64 = Vale.Def.Words_s.nat64
let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_64 i
unfold let quad32 = Vale.Def.Types_s.quad32
type reg = i:int{0 <= i /\ i < 32}
type vec = i:int{0 <= i /\ i < 32}
// Immediate operand of logical compare, and, or, and xor instructions
type imm16 = i:int{0 <= i && i <= 65535}
// Immediate operand of compare, add (with signed immediate) instructions
type simm16 = i:int{-32768 <= i && i <= 32767}
// Immediate operand of sub (with negative signed immediate) instruction
type nsimm16 = i:int{-32767 <= i && i <= 32768}
// Immediate operand of rotate, shift, and clear for 64-bit instructions
type bits64 = i:int{0 <= i && i < 64}
// Immediate operand of rotate, shift, and clear for 32-bit instructions
type bits32 = i:int{0 <= i && i < 32}
// Immediate operand of vector shift left double by octet
type quad32bytes = i:int{0 <= i && i < 16}
// Immediate operand of vector splat
type sim = i:int{-16 <= i && i < 15} | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.FunctionalExtensionality.restricted_t",
"Vale.PPC64LE.Machine_s.reg",
"Vale.PPC64LE.Machine_s.nat64"
] | [] | false | false | false | true | true | let regs_t =
| FStar.FunctionalExtensionality.restricted_t reg (fun _ -> nat64) | false |
|
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.regs_make | val regs_make (f: (reg -> nat64)) : regs_t | val regs_make (f: (reg -> nat64)) : regs_t | let regs_make (f:reg -> nat64) : regs_t = FStar.FunctionalExtensionality.on_dom reg f | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 104,
"end_line": 42,
"start_col": 19,
"start_line": 42
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i
unfold let nat64 = Vale.Def.Words_s.nat64
let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_64 i
unfold let quad32 = Vale.Def.Types_s.quad32
type reg = i:int{0 <= i /\ i < 32}
type vec = i:int{0 <= i /\ i < 32}
// Immediate operand of logical compare, and, or, and xor instructions
type imm16 = i:int{0 <= i && i <= 65535}
// Immediate operand of compare, add (with signed immediate) instructions
type simm16 = i:int{-32768 <= i && i <= 32767}
// Immediate operand of sub (with negative signed immediate) instruction
type nsimm16 = i:int{-32767 <= i && i <= 32768}
// Immediate operand of rotate, shift, and clear for 64-bit instructions
type bits64 = i:int{0 <= i && i < 64}
// Immediate operand of rotate, shift, and clear for 32-bit instructions
type bits32 = i:int{0 <= i && i < 32}
// Immediate operand of vector shift left double by octet
type quad32bytes = i:int{0 <= i && i < 16}
// Immediate operand of vector splat
type sim = i:int{-16 <= i && i < 15}
let regs_t = FStar.FunctionalExtensionality.restricted_t reg (fun _ -> nat64) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: (_: Vale.PPC64LE.Machine_s.reg -> Vale.PPC64LE.Machine_s.nat64) -> Vale.PPC64LE.Machine_s.regs_t | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Machine_s.reg",
"Vale.PPC64LE.Machine_s.nat64",
"FStar.FunctionalExtensionality.on_dom",
"Vale.PPC64LE.Machine_s.regs_t"
] | [] | false | false | false | true | false | let regs_make (f: (reg -> nat64)) : regs_t =
| FStar.FunctionalExtensionality.on_dom reg f | false |
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.valid_maddr_offset | val valid_maddr_offset (n: int) : bool | val valid_maddr_offset (n: int) : bool | let valid_maddr_offset (n:int) : bool =
n >= -32768 && n <= 32767 | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 93,
"start_col": 0,
"start_line": 92
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i
unfold let nat64 = Vale.Def.Words_s.nat64
let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_64 i
unfold let quad32 = Vale.Def.Types_s.quad32
type reg = i:int{0 <= i /\ i < 32}
type vec = i:int{0 <= i /\ i < 32}
// Immediate operand of logical compare, and, or, and xor instructions
type imm16 = i:int{0 <= i && i <= 65535}
// Immediate operand of compare, add (with signed immediate) instructions
type simm16 = i:int{-32768 <= i && i <= 32767}
// Immediate operand of sub (with negative signed immediate) instruction
type nsimm16 = i:int{-32767 <= i && i <= 32768}
// Immediate operand of rotate, shift, and clear for 64-bit instructions
type bits64 = i:int{0 <= i && i < 64}
// Immediate operand of rotate, shift, and clear for 32-bit instructions
type bits32 = i:int{0 <= i && i < 32}
// Immediate operand of vector shift left double by octet
type quad32bytes = i:int{0 <= i && i < 16}
// Immediate operand of vector splat
type sim = i:int{-16 <= i && i < 15}
let regs_t = FStar.FunctionalExtensionality.restricted_t reg (fun _ -> nat64)
let vecs_t = FStar.FunctionalExtensionality.restricted_t vec (fun _ -> quad32)
[@va_qattr] unfold let regs_make (f:reg -> nat64) : regs_t = FStar.FunctionalExtensionality.on_dom reg f
[@va_qattr] unfold let vecs_make (f:vec -> quad32) : vecs_t = FStar.FunctionalExtensionality.on_dom vec f
// Condition Register (CR) Field 0 is interpreted as individual 4-bits that can be set as the implicit
// results of certain fixed-point instructions.
// Fixed-point compare instructions in which CR field operand is default or 0 and fixed-point arithmetic
// instructions that have "." suffix in the instruction mnemonic (Rc=1) alter the CR Field 0 (CR0) fields.
// The fourth bit of CR0 reflects the Summary Overflow (SO) field of Fixed-Point Exception Register (XER).
type cr0_t = {
lt:bool; // negative result
gt:bool; // positive result
eq:bool; // zero result
}
// Fixed-Point Exception Register (XER) stores the status of overflow and carry occurrences of
// instructions that can overflow with OE=1 and carry. Compare instructions don't alter XER.
type xer_t = {
ov:bool; // Overflow
ca:bool; // Carry
}
noeq
type machine_stack =
| Machine_stack:
initial_r1:nat64{initial_r1 >= 65536} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
noeq type state = {
ok: bool;
regs: regs_t;
vecs: vecs_t;
cr0: cr0_t;
xer: xer_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
}
let get_cr0 (r:nat64) =
{ lt = r >= 0x8000000000000000; gt = r < 0x8000000000000000; eq = r = 0 }
type maddr = {
address: reg;
offset: int
}
type tmaddr:eqtype = maddr & taint | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.int -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.op_AmpAmp",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Minus",
"Prims.op_LessThanOrEqual",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_maddr_offset (n: int) : bool =
| n >= - 32768 && n <= 32767 | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.len_lt_max_a_t | val len_lt_max_a_t : a: Spec.Hash.Definitions.sha2_alg -> Type0 | let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a} | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 77,
"end_line": 13,
"start_col": 0,
"start_line": 13
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Prims.nat",
"Prims.b2t",
"Spec.Hash.Definitions.less_than_max_input_length"
] | [] | false | false | false | true | true | let len_lt_max_a_t (a: sha2_alg) =
| len: nat{len `less_than_max_input_length` a} | false |
|
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.vecs_make | val vecs_make (f: (vec -> quad32)) : vecs_t | val vecs_make (f: (vec -> quad32)) : vecs_t | let vecs_make (f:vec -> quad32) : vecs_t = FStar.FunctionalExtensionality.on_dom vec f | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 105,
"end_line": 43,
"start_col": 19,
"start_line": 43
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i
unfold let nat64 = Vale.Def.Words_s.nat64
let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_64 i
unfold let quad32 = Vale.Def.Types_s.quad32
type reg = i:int{0 <= i /\ i < 32}
type vec = i:int{0 <= i /\ i < 32}
// Immediate operand of logical compare, and, or, and xor instructions
type imm16 = i:int{0 <= i && i <= 65535}
// Immediate operand of compare, add (with signed immediate) instructions
type simm16 = i:int{-32768 <= i && i <= 32767}
// Immediate operand of sub (with negative signed immediate) instruction
type nsimm16 = i:int{-32767 <= i && i <= 32768}
// Immediate operand of rotate, shift, and clear for 64-bit instructions
type bits64 = i:int{0 <= i && i < 64}
// Immediate operand of rotate, shift, and clear for 32-bit instructions
type bits32 = i:int{0 <= i && i < 32}
// Immediate operand of vector shift left double by octet
type quad32bytes = i:int{0 <= i && i < 16}
// Immediate operand of vector splat
type sim = i:int{-16 <= i && i < 15}
let regs_t = FStar.FunctionalExtensionality.restricted_t reg (fun _ -> nat64)
let vecs_t = FStar.FunctionalExtensionality.restricted_t vec (fun _ -> quad32) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: (_: Vale.PPC64LE.Machine_s.vec -> Vale.PPC64LE.Machine_s.quad32) -> Vale.PPC64LE.Machine_s.vecs_t | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Machine_s.vec",
"Vale.PPC64LE.Machine_s.quad32",
"FStar.FunctionalExtensionality.on_dom",
"Vale.PPC64LE.Machine_s.vecs_t"
] | [] | false | false | false | true | false | let vecs_make (f: (vec -> quad32)) : vecs_t =
| FStar.FunctionalExtensionality.on_dom vec f | false |
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.get_cr0 | val get_cr0 : r: Vale.PPC64LE.Machine_s.nat64 -> Vale.PPC64LE.Machine_s.cr0_t | let get_cr0 (r:nat64) =
{ lt = r >= 0x8000000000000000; gt = r < 0x8000000000000000; eq = r = 0 } | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 75,
"end_line": 82,
"start_col": 0,
"start_line": 81
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i
unfold let nat64 = Vale.Def.Words_s.nat64
let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_64 i
unfold let quad32 = Vale.Def.Types_s.quad32
type reg = i:int{0 <= i /\ i < 32}
type vec = i:int{0 <= i /\ i < 32}
// Immediate operand of logical compare, and, or, and xor instructions
type imm16 = i:int{0 <= i && i <= 65535}
// Immediate operand of compare, add (with signed immediate) instructions
type simm16 = i:int{-32768 <= i && i <= 32767}
// Immediate operand of sub (with negative signed immediate) instruction
type nsimm16 = i:int{-32767 <= i && i <= 32768}
// Immediate operand of rotate, shift, and clear for 64-bit instructions
type bits64 = i:int{0 <= i && i < 64}
// Immediate operand of rotate, shift, and clear for 32-bit instructions
type bits32 = i:int{0 <= i && i < 32}
// Immediate operand of vector shift left double by octet
type quad32bytes = i:int{0 <= i && i < 16}
// Immediate operand of vector splat
type sim = i:int{-16 <= i && i < 15}
let regs_t = FStar.FunctionalExtensionality.restricted_t reg (fun _ -> nat64)
let vecs_t = FStar.FunctionalExtensionality.restricted_t vec (fun _ -> quad32)
[@va_qattr] unfold let regs_make (f:reg -> nat64) : regs_t = FStar.FunctionalExtensionality.on_dom reg f
[@va_qattr] unfold let vecs_make (f:vec -> quad32) : vecs_t = FStar.FunctionalExtensionality.on_dom vec f
// Condition Register (CR) Field 0 is interpreted as individual 4-bits that can be set as the implicit
// results of certain fixed-point instructions.
// Fixed-point compare instructions in which CR field operand is default or 0 and fixed-point arithmetic
// instructions that have "." suffix in the instruction mnemonic (Rc=1) alter the CR Field 0 (CR0) fields.
// The fourth bit of CR0 reflects the Summary Overflow (SO) field of Fixed-Point Exception Register (XER).
type cr0_t = {
lt:bool; // negative result
gt:bool; // positive result
eq:bool; // zero result
}
// Fixed-Point Exception Register (XER) stores the status of overflow and carry occurrences of
// instructions that can overflow with OE=1 and carry. Compare instructions don't alter XER.
type xer_t = {
ov:bool; // Overflow
ca:bool; // Carry
}
noeq
type machine_stack =
| Machine_stack:
initial_r1:nat64{initial_r1 >= 65536} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
noeq type state = {
ok: bool;
regs: regs_t;
vecs: vecs_t;
cr0: cr0_t;
xer: xer_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
} | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: Vale.PPC64LE.Machine_s.nat64 -> Vale.PPC64LE.Machine_s.cr0_t | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Machine_s.nat64",
"Vale.PPC64LE.Machine_s.Mkcr0_t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Equality",
"Prims.int",
"Vale.PPC64LE.Machine_s.cr0_t"
] | [] | false | false | false | true | false | let get_cr0 (r: nat64) =
| { lt = r >= 0x8000000000000000; gt = r < 0x8000000000000000; eq = r = 0 } | false |
|
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.valid_maddr_offset64 | val valid_maddr_offset64 (n: int) : bool | val valid_maddr_offset64 (n: int) : bool | let valid_maddr_offset64 (n:int) : bool =
n >= -32768 && n <= 32764 && n % 4 = 0 | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 97,
"start_col": 0,
"start_line": 96
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i
unfold let nat64 = Vale.Def.Words_s.nat64
let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_64 i
unfold let quad32 = Vale.Def.Types_s.quad32
type reg = i:int{0 <= i /\ i < 32}
type vec = i:int{0 <= i /\ i < 32}
// Immediate operand of logical compare, and, or, and xor instructions
type imm16 = i:int{0 <= i && i <= 65535}
// Immediate operand of compare, add (with signed immediate) instructions
type simm16 = i:int{-32768 <= i && i <= 32767}
// Immediate operand of sub (with negative signed immediate) instruction
type nsimm16 = i:int{-32767 <= i && i <= 32768}
// Immediate operand of rotate, shift, and clear for 64-bit instructions
type bits64 = i:int{0 <= i && i < 64}
// Immediate operand of rotate, shift, and clear for 32-bit instructions
type bits32 = i:int{0 <= i && i < 32}
// Immediate operand of vector shift left double by octet
type quad32bytes = i:int{0 <= i && i < 16}
// Immediate operand of vector splat
type sim = i:int{-16 <= i && i < 15}
let regs_t = FStar.FunctionalExtensionality.restricted_t reg (fun _ -> nat64)
let vecs_t = FStar.FunctionalExtensionality.restricted_t vec (fun _ -> quad32)
[@va_qattr] unfold let regs_make (f:reg -> nat64) : regs_t = FStar.FunctionalExtensionality.on_dom reg f
[@va_qattr] unfold let vecs_make (f:vec -> quad32) : vecs_t = FStar.FunctionalExtensionality.on_dom vec f
// Condition Register (CR) Field 0 is interpreted as individual 4-bits that can be set as the implicit
// results of certain fixed-point instructions.
// Fixed-point compare instructions in which CR field operand is default or 0 and fixed-point arithmetic
// instructions that have "." suffix in the instruction mnemonic (Rc=1) alter the CR Field 0 (CR0) fields.
// The fourth bit of CR0 reflects the Summary Overflow (SO) field of Fixed-Point Exception Register (XER).
type cr0_t = {
lt:bool; // negative result
gt:bool; // positive result
eq:bool; // zero result
}
// Fixed-Point Exception Register (XER) stores the status of overflow and carry occurrences of
// instructions that can overflow with OE=1 and carry. Compare instructions don't alter XER.
type xer_t = {
ov:bool; // Overflow
ca:bool; // Carry
}
noeq
type machine_stack =
| Machine_stack:
initial_r1:nat64{initial_r1 >= 65536} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
noeq type state = {
ok: bool;
regs: regs_t;
vecs: vecs_t;
cr0: cr0_t;
xer: xer_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
}
let get_cr0 (r:nat64) =
{ lt = r >= 0x8000000000000000; gt = r < 0x8000000000000000; eq = r = 0 }
type maddr = {
address: reg;
offset: int
}
type tmaddr:eqtype = maddr & taint
// Memory offset bound of 32-bit, 16-bit, and 8-bit load/store instructions
let valid_maddr_offset (n:int) : bool =
n >= -32768 && n <= 32767 | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.int -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.op_AmpAmp",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Minus",
"Prims.op_LessThanOrEqual",
"Prims.op_Equality",
"Prims.op_Modulus",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_maddr_offset64 (n: int) : bool =
| n >= - 32768 && n <= 32764 && n % 4 = 0 | false |
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.valid_maddr_offset128 | val valid_maddr_offset128 (n: int) : bool | val valid_maddr_offset128 (n: int) : bool | let valid_maddr_offset128 (n:int) : bool =
n >= -32768 && n <= 32752 && n % 16 = 0 | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 101,
"start_col": 0,
"start_line": 100
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i
unfold let nat64 = Vale.Def.Words_s.nat64
let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_64 i
unfold let quad32 = Vale.Def.Types_s.quad32
type reg = i:int{0 <= i /\ i < 32}
type vec = i:int{0 <= i /\ i < 32}
// Immediate operand of logical compare, and, or, and xor instructions
type imm16 = i:int{0 <= i && i <= 65535}
// Immediate operand of compare, add (with signed immediate) instructions
type simm16 = i:int{-32768 <= i && i <= 32767}
// Immediate operand of sub (with negative signed immediate) instruction
type nsimm16 = i:int{-32767 <= i && i <= 32768}
// Immediate operand of rotate, shift, and clear for 64-bit instructions
type bits64 = i:int{0 <= i && i < 64}
// Immediate operand of rotate, shift, and clear for 32-bit instructions
type bits32 = i:int{0 <= i && i < 32}
// Immediate operand of vector shift left double by octet
type quad32bytes = i:int{0 <= i && i < 16}
// Immediate operand of vector splat
type sim = i:int{-16 <= i && i < 15}
let regs_t = FStar.FunctionalExtensionality.restricted_t reg (fun _ -> nat64)
let vecs_t = FStar.FunctionalExtensionality.restricted_t vec (fun _ -> quad32)
[@va_qattr] unfold let regs_make (f:reg -> nat64) : regs_t = FStar.FunctionalExtensionality.on_dom reg f
[@va_qattr] unfold let vecs_make (f:vec -> quad32) : vecs_t = FStar.FunctionalExtensionality.on_dom vec f
// Condition Register (CR) Field 0 is interpreted as individual 4-bits that can be set as the implicit
// results of certain fixed-point instructions.
// Fixed-point compare instructions in which CR field operand is default or 0 and fixed-point arithmetic
// instructions that have "." suffix in the instruction mnemonic (Rc=1) alter the CR Field 0 (CR0) fields.
// The fourth bit of CR0 reflects the Summary Overflow (SO) field of Fixed-Point Exception Register (XER).
type cr0_t = {
lt:bool; // negative result
gt:bool; // positive result
eq:bool; // zero result
}
// Fixed-Point Exception Register (XER) stores the status of overflow and carry occurrences of
// instructions that can overflow with OE=1 and carry. Compare instructions don't alter XER.
type xer_t = {
ov:bool; // Overflow
ca:bool; // Carry
}
noeq
type machine_stack =
| Machine_stack:
initial_r1:nat64{initial_r1 >= 65536} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
noeq type state = {
ok: bool;
regs: regs_t;
vecs: vecs_t;
cr0: cr0_t;
xer: xer_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
}
let get_cr0 (r:nat64) =
{ lt = r >= 0x8000000000000000; gt = r < 0x8000000000000000; eq = r = 0 }
type maddr = {
address: reg;
offset: int
}
type tmaddr:eqtype = maddr & taint
// Memory offset bound of 32-bit, 16-bit, and 8-bit load/store instructions
let valid_maddr_offset (n:int) : bool =
n >= -32768 && n <= 32767
// Memory offset bound of 64-bit load/store instructions
let valid_maddr_offset64 (n:int) : bool =
n >= -32768 && n <= 32764 && n % 4 = 0 | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.int -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.op_AmpAmp",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Minus",
"Prims.op_LessThanOrEqual",
"Prims.op_Equality",
"Prims.op_Modulus",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_maddr_offset128 (n: int) : bool =
| n >= - 32768 && n <= 32752 && n % 16 = 0 | false |
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.valid_first_cmp_opr | val valid_first_cmp_opr (o: cmp_opr) : bool | val valid_first_cmp_opr (o: cmp_opr) : bool | let valid_first_cmp_opr (o:cmp_opr) : bool =
CReg? o | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 9,
"end_line": 108,
"start_col": 0,
"start_line": 107
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i
unfold let nat64 = Vale.Def.Words_s.nat64
let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_64 i
unfold let quad32 = Vale.Def.Types_s.quad32
type reg = i:int{0 <= i /\ i < 32}
type vec = i:int{0 <= i /\ i < 32}
// Immediate operand of logical compare, and, or, and xor instructions
type imm16 = i:int{0 <= i && i <= 65535}
// Immediate operand of compare, add (with signed immediate) instructions
type simm16 = i:int{-32768 <= i && i <= 32767}
// Immediate operand of sub (with negative signed immediate) instruction
type nsimm16 = i:int{-32767 <= i && i <= 32768}
// Immediate operand of rotate, shift, and clear for 64-bit instructions
type bits64 = i:int{0 <= i && i < 64}
// Immediate operand of rotate, shift, and clear for 32-bit instructions
type bits32 = i:int{0 <= i && i < 32}
// Immediate operand of vector shift left double by octet
type quad32bytes = i:int{0 <= i && i < 16}
// Immediate operand of vector splat
type sim = i:int{-16 <= i && i < 15}
let regs_t = FStar.FunctionalExtensionality.restricted_t reg (fun _ -> nat64)
let vecs_t = FStar.FunctionalExtensionality.restricted_t vec (fun _ -> quad32)
[@va_qattr] unfold let regs_make (f:reg -> nat64) : regs_t = FStar.FunctionalExtensionality.on_dom reg f
[@va_qattr] unfold let vecs_make (f:vec -> quad32) : vecs_t = FStar.FunctionalExtensionality.on_dom vec f
// Condition Register (CR) Field 0 is interpreted as individual 4-bits that can be set as the implicit
// results of certain fixed-point instructions.
// Fixed-point compare instructions in which CR field operand is default or 0 and fixed-point arithmetic
// instructions that have "." suffix in the instruction mnemonic (Rc=1) alter the CR Field 0 (CR0) fields.
// The fourth bit of CR0 reflects the Summary Overflow (SO) field of Fixed-Point Exception Register (XER).
type cr0_t = {
lt:bool; // negative result
gt:bool; // positive result
eq:bool; // zero result
}
// Fixed-Point Exception Register (XER) stores the status of overflow and carry occurrences of
// instructions that can overflow with OE=1 and carry. Compare instructions don't alter XER.
type xer_t = {
ov:bool; // Overflow
ca:bool; // Carry
}
noeq
type machine_stack =
| Machine_stack:
initial_r1:nat64{initial_r1 >= 65536} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
noeq type state = {
ok: bool;
regs: regs_t;
vecs: vecs_t;
cr0: cr0_t;
xer: xer_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
}
let get_cr0 (r:nat64) =
{ lt = r >= 0x8000000000000000; gt = r < 0x8000000000000000; eq = r = 0 }
type maddr = {
address: reg;
offset: int
}
type tmaddr:eqtype = maddr & taint
// Memory offset bound of 32-bit, 16-bit, and 8-bit load/store instructions
let valid_maddr_offset (n:int) : bool =
n >= -32768 && n <= 32767
// Memory offset bound of 64-bit load/store instructions
let valid_maddr_offset64 (n:int) : bool =
n >= -32768 && n <= 32764 && n % 4 = 0
// Memory offset bound of 128-bit load/store instructions
let valid_maddr_offset128 (n:int) : bool =
n >= -32768 && n <= 32752 && n % 16 = 0
type cmp_opr =
| CReg: r:reg -> cmp_opr
| CImm: n:imm16 -> cmp_opr | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | o: Vale.PPC64LE.Machine_s.cmp_opr -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Machine_s.cmp_opr",
"Vale.PPC64LE.Machine_s.uu___is_CReg",
"Prims.bool"
] | [] | false | false | false | true | false | let valid_first_cmp_opr (o: cmp_opr) : bool =
| CReg? o | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.op224_256 | val op224_256:ops | val op224_256:ops | let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
} | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 1,
"end_line": 66,
"start_col": 0,
"start_line": 61
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *) | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.Spec.SHA2.ops | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.SHA2.Mkops",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | true | false | let op224_256:ops =
| {
c0 = 2ul;
c1 = 13ul;
c2 = 22ul;
c3 = 6ul;
c4 = 11ul;
c5 = 25ul;
e0 = 7ul;
e1 = 18ul;
e2 = 3ul;
e3 = 17ul;
e4 = 19ul;
e5 = 10ul
} | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.op384_512 | val op384_512:ops | val op384_512:ops | let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
} | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 1,
"end_line": 74,
"start_col": 0,
"start_line": 69
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
} | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.Spec.SHA2.ops | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.SHA2.Mkops",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | true | false | let op384_512:ops =
| {
c0 = 28ul;
c1 = 34ul;
c2 = 39ul;
c3 = 14ul;
c4 = 18ul;
c5 = 41ul;
e0 = 1ul;
e1 = 8ul;
e2 = 7ul;
e3 = 19ul;
e4 = 61ul;
e5 = 6ul
} | false |
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.int_to_nat8 | val int_to_nat8 (i: int) : n: nat8{0 <= i && i < pow2_8 ==> i == n} | val int_to_nat8 (i: int) : n: nat8{0 <= i && i < pow2_8 ==> i == n} | let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 14,
"start_col": 0,
"start_line": 13
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16 | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: Prims.int
-> n: Vale.PPC64LE.Machine_s.nat8{0 <= i && i < Vale.PPC64LE.Machine_s.pow2_8 ==> i == n} | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Def.Words_s.int_to_natN",
"Vale.PPC64LE.Machine_s.pow2_8",
"Vale.PPC64LE.Machine_s.nat8",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.eq2"
] | [] | false | false | false | false | false | let int_to_nat8 (i: int) : n: nat8{0 <= i && i < pow2_8 ==> i == n} =
| Vale.Def.Words_s.int_to_natN pow2_8 i | false |
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.int_to_nat32 | val int_to_nat32 (i: int) : n: nat32{0 <= i && i < pow2_32 ==> i == n} | val int_to_nat32 (i: int) : n: nat32{0 <= i && i < pow2_32 ==> i == n} | let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 16,
"start_col": 0,
"start_line": 15
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} = | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: Prims.int
-> n: Vale.PPC64LE.Machine_s.nat32{0 <= i && i < Vale.PPC64LE.Machine_s.pow2_32 ==> i == n} | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Def.Words_s.int_to_natN",
"Vale.PPC64LE.Machine_s.pow2_32",
"Vale.PPC64LE.Machine_s.nat32",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.eq2"
] | [] | false | false | false | false | false | let int_to_nat32 (i: int) : n: nat32{0 <= i && i < pow2_32 ==> i == n} =
| Vale.Def.Words_s.int_to_natN pow2_32 i | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.size_k_w | val size_k_w: sha2_alg -> Tot nat | val size_k_w: sha2_alg -> Tot nat | let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80 | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 29,
"start_col": 0,
"start_line": 27
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *) | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Spec.Hash.Definitions.sha2_alg -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Prims.nat"
] | [] | false | false | false | true | false | let size_k_w: sha2_alg -> Tot nat =
| function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80 | false |
Vale.PPC64LE.Machine_s.fst | Vale.PPC64LE.Machine_s.int_to_nat64 | val int_to_nat64 (i: int) : n: nat64{0 <= i && i < pow2_64 ==> i == n} | val int_to_nat64 (i: int) : n: nat64{0 <= i && i < pow2_64 ==> i == n} | let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_64 i | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Machine_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 19,
"start_col": 0,
"start_line": 18
} | module Vale.PPC64LE.Machine_s
open Vale.Arch.Heap
include Vale.Arch.HeapTypes_s
irreducible let va_qattr = ()
unfold let pow2_8 = Vale.Def.Words_s.pow2_8
unfold let pow2_32 = Vale.Def.Words_s.pow2_32
unfold let pow2_64 = Vale.Def.Words_s.pow2_64
unfold let nat8 = Vale.Def.Words_s.nat8
unfold let nat16 = Vale.Def.Words_s.nat16
unfold let nat32 = Vale.Def.Words_s.nat32
let int_to_nat8 (i:int) : n:nat8{0 <= i && i < pow2_8 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_8 i
let int_to_nat32 (i:int) : n:nat32{0 <= i && i < pow2_32 ==> i == n} =
Vale.Def.Words_s.int_to_natN pow2_32 i | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Machine_s.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: Prims.int
-> n: Vale.PPC64LE.Machine_s.nat64{0 <= i && i < Vale.PPC64LE.Machine_s.pow2_64 ==> i == n} | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.Def.Words_s.int_to_natN",
"Vale.PPC64LE.Machine_s.pow2_64",
"Vale.PPC64LE.Machine_s.nat64",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.eq2"
] | [] | false | false | false | false | false | let int_to_nat64 (i: int) : n: nat64{0 <= i && i < pow2_64 ==> i == n} =
| Vale.Def.Words_s.int_to_natN pow2_64 i | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2._Ch | val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a) | val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a) | let _Ch a x y z = (x &. y) ^. (~.x &. z) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 123,
"start_col": 0,
"start_line": 123
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
x: Spec.Hash.Definitions.word a ->
y: Spec.Hash.Definitions.word a ->
z: Spec.Hash.Definitions.word a
-> Spec.Hash.Definitions.word a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.word",
"Hacl.Spec.SHA2.op_Hat_Dot",
"Hacl.Spec.SHA2.op_Amp_Dot",
"Hacl.Spec.SHA2.op_Tilde_Dot"
] | [] | false | false | false | false | false | let _Ch a x y z =
| (x &. y) ^. (~.x &. z) | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.word_n | val word_n: sha2_alg -> Tot nat | val word_n: sha2_alg -> Tot nat | let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64 | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 34,
"start_col": 0,
"start_line": 32
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80 | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Spec.Hash.Definitions.sha2_alg -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Prims.nat"
] | [] | false | false | false | true | false | let word_n: sha2_alg -> Tot nat =
| function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64 | false |
Hacl.Impl.SHA2.Generic.fst | Hacl.Impl.SHA2.Generic.update | val update: #a:sha2_alg -> #m:m_spec{is_supported a m} -> update_vec_t a m | val update: #a:sha2_alg -> #m:m_spec{is_supported a m} -> update_vec_t a m | let update #a #m b hash =
let h0 = ST.get() in
push_frame ();
let h1 = ST.get() in
let hash_old = create 8ul (zero_element a m) in
let ws = create 16ul (zero_element a m) in
assert (disjoint_multi b hash_old);
assert (disjoint_multi b ws);
assert (disjoint ws hash_old);
assert (disjoint hash hash_old);
assert (disjoint ws hash);
copy hash_old hash;
let h2 = ST.get() in
assert (live_multi h2 b);
NTup.(eq_intro (as_seq_multi h2 b) (as_seq_multi h0 b));
load_ws b ws;
let h3 = ST.get() in
assert (modifies (loc ws |+| loc hash_old) h0 h3);
assert (as_seq h3 ws == SpecVec.load_ws (as_seq_multi h2 b));
shuffle ws hash;
let h4 = ST.get() in
assert (modifies (loc hash |+| (loc ws |+| loc hash_old)) h0 h4);
assert (as_seq h4 hash == SpecVec.shuffle (as_seq h3 ws) (as_seq h0 hash));
map2T 8ul hash (+|) hash hash_old;
let h5 = ST.get() in
assert (modifies (loc hash |+| (loc ws |+| loc hash_old)) h0 h5);
reveal_opaque (`%SpecVec.update) (SpecVec.update #a #m);
assert (as_seq h5 hash == SpecVec.update (as_seq_multi h0 b) (as_seq h0 hash));
pop_frame() | {
"file_name": "code/sha2-mb/Hacl.Impl.SHA2.Generic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 231,
"start_col": 0,
"start_line": 203
} | module Hacl.Impl.SHA2.Generic
open FStar.Mul
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.NTuple
open Lib.Buffer
open Lib.IntVector
open Lib.MultiBuffer
open Spec.Hash.Definitions
//open Hacl.Hash.Definitions
open Hacl.Spec.SHA2.Vec
open Hacl.Impl.SHA2.Core
module ST = FStar.HyperStack.ST
module NTup = Lib.NTuple
module Constants = Spec.SHA2.Constants
module Spec = Hacl.Spec.SHA2
module SpecVec = Hacl.Spec.SHA2.Vec
module VecTranspose = Lib.IntVector.Transpose
module LSeq = Lib.Sequence
module HD = Hacl.Hash.Definitions
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50"
(** Top-level constant arrays for the SHA2 algorithms. *)
let h224 : x:glbuffer uint32 8ul{witnessed x Constants.h224 /\ recallable x} =
createL_global Constants.h224_l
let h256 : x:glbuffer uint32 8ul{witnessed x Constants.h256 /\ recallable x} =
createL_global Constants.h256_l
let h384 : x:glbuffer uint64 8ul{witnessed x Constants.h384 /\ recallable x} =
createL_global Constants.h384_l
let h512 : x:glbuffer uint64 8ul{witnessed x Constants.h512 /\ recallable x} =
createL_global Constants.h512_l
noextract inline_for_extraction
let index_h0 (a:sha2_alg) (i:size_t) : Stack (word a)
(requires (fun _ -> size_v i < 8))
(ensures (fun h0 r h1 ->
h0 == h1 /\
r == Seq.index (Spec.h0 a) (size_v i))) =
match a with
| SHA2_224 -> recall h224; recall_contents h224 Constants.h224; h224.(i)
| SHA2_256 -> recall h256; recall_contents h256 Constants.h256; h256.(i)
| SHA2_384 -> recall h384; recall_contents h384 Constants.h384; h384.(i)
| SHA2_512 -> recall h512; recall_contents h512 Constants.h512; h512.(i)
let k224_256 : x:glbuffer uint32 64ul{witnessed x Constants.k224_256 /\ recallable x} =
createL_global Constants.k224_256_l
let k384_512 : x:glbuffer uint64 80ul{witnessed x Constants.k384_512 /\ recallable x} =
createL_global Constants.k384_512_l
noextract inline_for_extraction
let index_k0 (a:sha2_alg) (i:size_t) : Stack (word a)
(requires (fun _ -> size_v i < Spec.size_k_w a))
(ensures (fun h0 r h1 ->
h0 == h1 /\
r == Seq.index (Spec.k0 a) (size_v i))) =
match a with
| SHA2_224 | SHA2_256 ->
recall_contents k224_256 Constants.k224_256;
k224_256.(i)
| SHA2_384 | SHA2_512 ->
recall_contents k384_512 Constants.k384_512;
k384_512.(i)
inline_for_extraction noextract
val shuffle_core: #a:sha2_alg -> #m:m_spec
-> k_t:word a
-> ws_t:element_t a m
-> st:state_t a m ->
Stack unit
(requires fun h -> live h st)
(ensures fun h0 _ h1 ->
modifies (loc st) h0 h1 /\
as_seq h1 st == SpecVec.shuffle_core_spec k_t ws_t (as_seq h0 st))
let shuffle_core #a #m k_t ws_t st =
let hp0 = ST.get() in
let a0 = st.(0ul) in
let b0 = st.(1ul) in
let c0 = st.(2ul) in
let d0 = st.(3ul) in
let e0 = st.(4ul) in
let f0 = st.(5ul) in
let g0 = st.(6ul) in
let h0 = st.(7ul) in
let k_e_t = load_element a m k_t in
let t1 = h0 +| (_Sigma1 e0) +| (_Ch e0 f0 g0) +| k_e_t +| ws_t in
let t2 = (_Sigma0 a0) +| (_Maj a0 b0 c0) in
let a1 = t1 +| t2 in
let b1 = a0 in
let c1 = b0 in
let d1 = c0 in
let e1 = d0 +| t1 in
let f1 = e0 in
let g1 = f0 in
let h1 = g0 in
create8 st a1 b1 c1 d1 e1 f1 g1 h1
#push-options "--z3rlimit 300"
inline_for_extraction noextract
val ws_next: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m ->
Stack unit
(requires fun h -> live h ws)
(ensures fun h0 _ h1 -> modifies (loc ws) h0 h1 /\
as_seq h1 ws == SpecVec.ws_next (as_seq h0 ws))
let ws_next #a #m ws =
let h0 = ST.get() in
loop1 h0 16ul ws
(fun h -> ws_next_inner #a #m)
(fun i ->
Lib.LoopCombinators.unfold_repeati 16 (ws_next_inner #a #m) (as_seq h0 ws) (v i);
let t16 = ws.(i) in
let t15 = ws.((i+.1ul) %. 16ul) in
let t7 = ws.((i+.9ul) %. 16ul) in
let t2 = ws.((i+.14ul) %. 16ul) in
let s1 = _sigma1 t2 in
let s0 = _sigma0 t15 in
ws.(i) <- (s1 +| t7 +| s0 +| t16))
#pop-options
inline_for_extraction noextract
val shuffle: #a:sha2_alg -> #m:m_spec -> ws:ws_t a m -> hash:state_t a m ->
Stack unit
(requires fun h -> live h hash /\ live h ws /\ disjoint hash ws)
(ensures fun h0 _ h1 -> modifies2 ws hash h0 h1 /\
as_seq h1 hash == SpecVec.shuffle #a #m (as_seq h0 ws) (as_seq h0 hash))
let shuffle #a #m ws hash =
let h0 = ST.get() in
loop2 h0 (num_rounds16 a) ws hash
(fun h -> shuffle_inner_loop #a #m)
(fun i ->
Lib.LoopCombinators.unfold_repeati (v (num_rounds16 a)) (shuffle_inner_loop #a #m) (as_seq h0 ws, as_seq h0 hash) (v i);
let h1 = ST.get() in
loop1 h1 16ul hash
(fun h -> shuffle_inner #a #m (as_seq h1 ws) (v i))
(fun j ->
Lib.LoopCombinators.unfold_repeati 16 (shuffle_inner #a #m (as_seq h1 ws) (v i)) (as_seq h1 hash) (v j);
let k_t = index_k0 a (16ul *. i +. j) in
let ws_t = ws.(j) in
shuffle_core k_t ws_t hash);
if i <. num_rounds16 a -. 1ul then ws_next ws)
inline_for_extraction noextract
val alloc: a:sha2_alg -> m:m_spec ->
StackInline (state_t a m)
(requires fun h -> True)
(ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 (Seq.create 8 (zero_element a m)))
let alloc a m = Lib.Buffer.create 8ul (zero_element a m)
inline_for_extraction noextract
let init_vec_t (a:sha2_alg) (m:m_spec) = hash:state_t a m ->
Stack unit
(requires fun h -> live h hash)
(ensures fun h0 _ h1 -> modifies1 hash h0 h1 /\
as_seq h1 hash == SpecVec.init a m)
inline_for_extraction noextract
val init: #a:sha2_alg -> #m:m_spec -> init_vec_t a m
let init #a #m hash =
let h0 = ST.get() in
fill h0 8ul hash
(fun h i -> load_element a m (Seq.index (Spec.h0 a) i))
(fun i ->
let hi = index_h0 a i in
load_element a m hi);
let h1 = ST.get() in
LSeq.eq_intro (as_seq h1 hash) (LSeq.createi 8 (fun i -> load_element a m (Seq.index (Spec.h0 a) i)))
inline_for_extraction noextract
let update_vec_t (a:sha2_alg) (m:m_spec{is_supported a m}) =
b:multibuf (lanes a m) (HD.block_len a)
-> hash:state_t a m ->
Stack unit
(requires fun h -> live_multi h b /\ live h hash)
(ensures fun h0 _ h1 -> modifies (loc hash) h0 h1 /\
as_seq h1 hash == SpecVec.update (as_seq_multi h0 b) (as_seq h0 hash))
#push-options "--z3rlimit 200"
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntVector.Transpose.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.fst.checked",
"Hacl.Impl.SHA2.Core.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.SHA2.Generic.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "HD"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.IntVector.Transpose",
"short_module": "VecTranspose"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": "SpecVec"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.SHA2",
"short_module": "Spec"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "Constants"
},
{
"abbrev": true,
"full_module": "Lib.NTuple",
"short_module": "NTup"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Hacl.Impl.SHA2.Generic.update_vec_t a m | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.Vec.m_spec",
"Hacl.Spec.SHA2.Vec.is_supported",
"Lib.MultiBuffer.multibuf",
"Hacl.Spec.SHA2.Vec.lanes",
"Hacl.Hash.Definitions.block_len",
"Hacl.Impl.SHA2.Core.state_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Hacl.Spec.SHA2.Vec.element_t",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.UInt32.__uint_to_t",
"Hacl.Spec.SHA2.Vec.update",
"Lib.MultiBuffer.as_seq_multi",
"FStar.Pervasives.reveal_opaque",
"Hacl.Spec.SHA2.Vec.multiblock_spec",
"Hacl.Spec.SHA2.Vec.state_spec",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.map2T",
"Hacl.Spec.SHA2.Vec.op_Plus_Bar",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.SHA2.Vec.shuffle",
"Hacl.Impl.SHA2.Generic.shuffle",
"Hacl.Spec.SHA2.Vec.load_ws",
"Hacl.Impl.SHA2.Core.load_ws",
"Lib.NTuple.eq_intro",
"FStar.Seq.Properties.lseq",
"Lib.IntTypes.uint8",
"Lib.MultiBuffer.live_multi",
"Lib.Buffer.copy",
"Lib.Buffer.disjoint",
"Lib.MultiBuffer.disjoint_multi",
"Lib.Buffer.lbuffer_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Hacl.Spec.SHA2.Vec.zero_element",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let update #a #m b hash =
| let h0 = ST.get () in
push_frame ();
let h1 = ST.get () in
let hash_old = create 8ul (zero_element a m) in
let ws = create 16ul (zero_element a m) in
assert (disjoint_multi b hash_old);
assert (disjoint_multi b ws);
assert (disjoint ws hash_old);
assert (disjoint hash hash_old);
assert (disjoint ws hash);
copy hash_old hash;
let h2 = ST.get () in
assert (live_multi h2 b);
(let open NTup in eq_intro (as_seq_multi h2 b) (as_seq_multi h0 b));
load_ws b ws;
let h3 = ST.get () in
assert (modifies (loc ws |+| loc hash_old) h0 h3);
assert (as_seq h3 ws == SpecVec.load_ws (as_seq_multi h2 b));
shuffle ws hash;
let h4 = ST.get () in
assert (modifies (loc hash |+| (loc ws |+| loc hash_old)) h0 h4);
assert (as_seq h4 hash == SpecVec.shuffle (as_seq h3 ws) (as_seq h0 hash));
map2T 8ul hash ( +| ) hash hash_old;
let h5 = ST.get () in
assert (modifies (loc hash |+| (loc ws |+| loc hash_old)) h0 h5);
reveal_opaque (`%SpecVec.update) (SpecVec.update #a #m);
assert (as_seq h5 hash == SpecVec.update (as_seq_multi h0 b) (as_seq h0 hash));
pop_frame () | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2._Maj | val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a) | val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a) | let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z)) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 127,
"start_col": 0,
"start_line": 127
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
x: Spec.Hash.Definitions.word a ->
y: Spec.Hash.Definitions.word a ->
z: Spec.Hash.Definitions.word a
-> Spec.Hash.Definitions.word a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.word",
"Hacl.Spec.SHA2.op_Hat_Dot",
"Hacl.Spec.SHA2.op_Amp_Dot"
] | [] | false | false | false | false | false | let _Maj a x y z =
| (x &. y) ^. ((x &. z) ^. (y &. z)) | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.to_word | val to_word (a: sha2_alg) (n: nat{n < pow2 (word_n a)}) : word a | val to_word (a: sha2_alg) (n: nat{n < pow2 (word_n a)}) : word a | let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 40,
"start_col": 0,
"start_line": 37
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64 | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> n: Prims.nat{n < Prims.pow2 (Hacl.Spec.SHA2.word_n a)}
-> Spec.Hash.Definitions.word a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Hacl.Spec.SHA2.word_n",
"Lib.IntTypes.u32",
"Lib.IntTypes.u64",
"Spec.Hash.Definitions.word"
] | [] | false | false | false | false | false | let to_word (a: sha2_alg) (n: nat{n < pow2 (word_n a)}) : word a =
| match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.block_t | val block_t : a: Spec.Hash.Definitions.sha2_alg -> Type0 | let block_t (a: sha2_alg) = lseq uint8 (block_length a) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 55,
"end_line": 49,
"start_col": 0,
"start_line": 49
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5 | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.block_length"
] | [] | false | false | false | true | true | let block_t (a: sha2_alg) =
| lseq uint8 (block_length a) | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.num_rounds16 | val num_rounds16 (a: sha2_alg) : n: pos{16 * n == size_k_w a} | val num_rounds16 (a: sha2_alg) : n: pos{16 * n == size_k_w a} | let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5 | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 46,
"start_col": 0,
"start_line": 43
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> n: Prims.pos{16 * n == Hacl.Spec.SHA2.size_k_w a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Prims.pos",
"Prims.eq2",
"Prims.int",
"FStar.Mul.op_Star",
"Hacl.Spec.SHA2.size_k_w"
] | [] | false | false | false | false | false | let num_rounds16 (a: sha2_alg) : n: pos{16 * n == size_k_w a} =
| match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5 | false |
Steel.Preorder.fst | Steel.Preorder.pcm_history_induces_preorder | val pcm_history_induces_preorder (#a #p: _)
: Lemma (induces_preorder (pcm_history #a #p) (pcm_history_preorder #a #p)) | val pcm_history_induces_preorder (#a #p: _)
: Lemma (induces_preorder (pcm_history #a #p) (pcm_history_preorder #a #p)) | let pcm_history_induces_preorder #a #p
: Lemma (induces_preorder (pcm_history #a #p)
(pcm_history_preorder #a #p))
= let aux (x y:history a p)
(f:frame_preserving_upd (pcm_history #a #p) x y)
(v:history a p)
: Lemma
(requires compatible (pcm_history #a #p) x v)
(ensures (pcm_history_preorder #a #p) v (f v))
[SMTPat ()]
= let pcm = pcm_history #a #p in
let v1 = f v in
match x, v, v1 with
| Witnessed _, Witnessed _, Witnessed _ ->
assert (composable pcm x v)
| Current _ _, Witnessed _, Witnessed _ -> ()
| Witnessed _, Current _ _, Witnessed _ -> ()
| Witnessed _, Witnessed _, Current _ _ ->
assert (composable pcm x v)
| Current _ _, Witnessed _, Current _ _ -> ()
| Witnessed _, Current _ _, Current _ _ -> ()
| Current hx _, Current hv _, Witnessed _
| Current hx _, Current hv _, Current _ _ ->
let frame = FStar.IndefiniteDescription.indefinite_description_ghost
(history a p) (fun frame -> composable pcm x frame /\ op pcm frame x == v) in
match frame with
| Current hf _ -> ()
| Witnessed hf ->
assert (extends hx hf);
assert (hx == hv);
assert (composable pcm x (Witnessed hv))
in
() | {
"file_name": "lib/steel/Steel.Preorder.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 6,
"end_line": 409,
"start_col": 0,
"start_line": 377
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Preorder
open FStar.PCM
open FStar.Preorder
/// This module explores the connection between PCM and preorders. More specifically, we show here
/// that any PCM induces a preorder relation, characterized by frame-preservation for any updates.
///
/// Furthermore, we also consider the reverse relationship where we derive a PCM for any preorder,
/// by taking as elements of the PCM the trace of all the states of the element.
(**** PCM to preoder *)
(**
PCM [p] induces the preorder [q] if for any frame preserving update of [x] to [y],
the argument and result of the frame preserving update are related by q
*)
let induces_preorder (#a:Type u#a) (p:pcm a) (q:preorder a) =
forall (x y:a) (f:frame_preserving_upd p x y) (v:a).
p.refine v ==> compatible p x v ==> q v (f v)
(**
We can define a canonical preorder from any PCM by taking the quantified conjunction over all the
preorders [q] induced by this PCM.
*)
let preorder_of_pcm (#a:Type u#a) (p:pcm a) : preorder a =
fun x y -> forall (q:preorder a). induces_preorder p q ==> q x y
let frame_preserving_upd_is_preorder_preserving (#a:Type u#a) (p:pcm a)
(x y:a) (f:frame_preserving_upd p x y)
(v_old:a{p.refine v_old /\ compatible p x v_old})
: Lemma ((preorder_of_pcm p) v_old (f v_old))
= ()
(**
This canonical preorder enjoys the nice property that it preserves fact stability of any
induced preorder
*)
let stability (#a: Type u#a) (fact:a -> prop) (q:preorder a) (p:pcm a)
: Lemma
(requires stable fact q /\
induces_preorder p q)
(ensures stable fact (preorder_of_pcm p))
= ()
let stable_compatiblity (#a:Type u#a) (fact: a -> prop) (p:pcm a) (v v0 v1:a)
: Lemma
(requires
stable fact (preorder_of_pcm p) /\
p.refine v0 /\
fact v0 /\
p.refine v1 /\
frame_preserving p v v1 /\
compatible p v v0)
(ensures
fact v1)
= let f : frame_preserving_upd p v v1 = frame_preserving_val_to_fp_upd p v v1 in
frame_preserving_upd_is_preorder_preserving p v v1 f v0
(**** Preorder to PCM *)
(***** Building the preorder *)
(**
This predicate tells that the list [l] can represent a trace of elements whose evolution is
compatible with the preorder [q]
*)
let rec qhistory #a (q:preorder a) (l:list a) =
match l with
| []
| [_] -> True
| x::y::tl -> y `q` x /\ qhistory q (y::tl)
(** The history of a preorder is the type of all the traces compatible with that preorder *)
let hist (#a: Type u#a) (q:preorder a) = l:list a{qhistory q l}
(** Two compatible traces can extend each other *)
let rec extends' (#a: Type u#a) (#q:preorder a) (h0 h1:hist q) =
h0 == h1 \/ (Cons? h0 /\ extends' (Cons?.tl h0) h1)
(** This extension relation is transitive *)
let rec extends_trans #a (#q:preorder a) (x y z:hist q)
: Lemma (x `extends'` y /\ y `extends'` z ==> x `extends'` z)
[SMTPat (x `extends'` y);
SMTPat (y `extends'` z)]
= match x with
| [] -> ()
| _::tl -> extends_trans tl y z
(** And it is also reflexive, so extensibility on traces is a preorder on traces *)
let extends (#a: Type u#a) (#q:preorder a) : preorder (hist q) = extends'
module L = FStar.List.Tot
(** If [h0] extends by [h1], then the length of [h0] is superior *)
let rec extends_length_eq (#a: Type u#a) (#q:preorder a) (h0 h1:hist q)
: Lemma (ensures (extends h0 h1 ==> h0 == h1 \/ L.length h0 > L.length h1))
[SMTPat (extends h0 h1)]
= match h0 with
| [] -> ()
| hd::tl -> extends_length_eq tl h1
(**
We build our relation of composability for traces by reflexing the extension to ensure
symmetry
*)
let p_composable (#a: Type u#a) (q:preorder a) : symrel (hist q) =
fun x y -> extends x y \/ extends y x
(** The operation for the PCM is to return the full trace of two extensible traces *)
let p_op (#a: Type u#a) (q:preorder a) (x:hist q) (y:hist q{p_composable q x y}) : hist q =
if L.length x >= L.length y
then x
else if L.length x = L.length y
then (assert (x == y); x)
else y
(** The operation actually implements extension *)
let p_op_extends (#a: Type u#a) (q:preorder a) (x:hist q) (y:hist q{p_composable q x y})
: Lemma (ensures (p_op q x y `extends` x /\
p_op q x y `extends` y /\
(p_op q x y == x \/ p_op q x y == y)))
[SMTPat (p_op q x y)]
= extends_length_eq x y;
extends_length_eq y x
(** And the empty trace is the unit element *)
let rec p_op_nil (#a: Type u#a) (q:preorder a) (x:hist q)
: Lemma (ensures (p_composable q x [] /\ p_op q x [] == x))
[SMTPat (p_composable q x [])]
= match x with
| [] -> ()
| _::tl -> p_op_nil q tl
(** We can finally define our PCM with these operations *)
let p (#a: Type u#a) (q:preorder a) : pcm' (hist q) = {
composable = p_composable q;
op = p_op q;
one = []
}
(** Composability is commutative *)
let comm (#a: Type u#a) (q:preorder a) (x y:hist q)
: Lemma (requires p_composable q x y)
(ensures p_composable q y x)
= ()
(** As well as the compose operation *)
let comm_op (#a: Type u#a) (q:preorder a) (x:hist q) (y:hist q{p_composable q x y})
: Lemma (p_op q x y == p_op q y x)
= extends_length_eq x y;
extends_length_eq y x
(** If [z] extends [x] and [y], then [x] and [y] are extending one or another *)
let rec extends_disjunction (#a: Type u#a) (#q:preorder a) (x y z:hist q)
: Lemma (z `extends` x /\ z `extends` y ==> x `extends` y \/ y `extends` x)
[SMTPat (z `extends` x);
SMTPat (z `extends` y)]
= match z with
| [] -> ()
| _::tl -> extends_disjunction x y tl
(** If [x] extends [y], then the two heads of the traces are still related by the preorder *)
let rec extends_related_head (#a: Type u#a) (#q:preorder a) (x y:hist q)
: Lemma
(ensures
x `extends` y /\
Cons? x /\
Cons? y ==> Cons?.hd y `q` Cons?.hd x)
[SMTPat (x `extends` y)]
= match x with
| [] -> ()
| _::tl -> extends_related_head tl y
(** Finally, we can have our fully-fledged PCM from the preorder *)
let pcm_of_preorder (#a: Type u#a) (q:preorder a) : pcm (hist q) = {
p = p q;
comm = comm_op q;
assoc = (fun _ _ _ -> ());
assoc_r = (fun _ _ _ -> ());
is_unit = (fun _ -> ());
refine = (fun _ -> True)
}
(***** Using the preorder *)
(**
We check that the preorder derived from the PCM derived from the preorder
satisfies the same properties as the original preorder. Here, we get back history
extension from frame-preserving updates.
*)
let frame_preserving_q_aux (#a : Type u#a) (q:preorder a) (x y:hist q) (z:hist q)
: Lemma (requires (frame_preserving (pcm_of_preorder q) x y /\ compatible (pcm_of_preorder q) x z))
(ensures (y `extends` z))
= ()
(** A non-empty history *)
let vhist (#a: Type u#a) (q:preorder a) = h:hist q{Cons? h}
(** Get the current value from an history *)
let curval (#a: Type u#a) (#q:preorder a) (v:vhist q) = Cons?.hd v
(**
Given a frame-preserving update from [x] to [y]
for any value of resource [z] (compatible with [x])
the new value [y] advances the history [z] in a preorder respecting manner
*)
let frame_preserving_q (#a: Type u#a) (q:preorder a) (x y:vhist q)
: Lemma (requires frame_preserving (pcm_of_preorder q) x y)
(ensures (forall (z:hist q). compatible (pcm_of_preorder q) x z ==> curval z `q` curval y))
= ()
(** Still given a frame-preserving update from [x] to [y], this update extends the history *)
let frame_preserving_extends (#a: Type u#a) (q:preorder a) (x y:vhist q)
: Lemma (requires frame_preserving (pcm_of_preorder q) x y)
(ensures (forall (z:hist q). compatible (pcm_of_preorder q) x z ==> y `extends` z))
= ()
(** Helper function that flips a preoder *)
let flip (#a: Type u#a) (p:preorder a) : preorder a = fun x y -> p y x
(**
What is the preorder induced from the PCM induced by preorder [q]? It turns out that
it is the flipped of [q], reversed extension.
*)
let frame_preserving_extends2 (#a: Type u#a) (q:preorder a) (x y:hist q)
: Lemma (requires frame_preserving (pcm_of_preorder q) x y)
(ensures (forall (z:hist q). compatible (pcm_of_preorder q) x z ==> z `flip extends` y))
[SMTPat (frame_preserving (pcm_of_preorder q) x y)]
= ()
#push-options "--warn_error -271"
let pcm_of_preorder_induces_extends (#a: Type u#a) (q:preorder a)
: Lemma (induces_preorder (pcm_of_preorder q) (flip extends))
= let fp_full (x y:hist q) (f:frame_preserving_upd (pcm_of_preorder q) x y) (v:hist q)
: Lemma (requires compatible (pcm_of_preorder q) x v)
(ensures extends (f v) v)
[SMTPat ()]
= assert (composable (pcm_of_preorder q) x v) in
()
#pop-options
let extend_history (#a:Type u#a) (#q:preorder a) (h0:vhist q) (v:a{q (curval h0) v})
: h1:vhist q{h1 `extends` h0}
= v :: h0
let property (a:Type)
= a -> prop
let stable_property (#a:Type) (pcm:pcm a)
= fact:property a {
FStar.Preorder.stable fact (preorder_of_pcm pcm)
}
let fact_valid_compat (#a:Type) (#pcm:pcm a)
(fact:stable_property pcm)
(v:a)
= forall z. compatible pcm v z ==> fact z
open Steel.FractionalPermission
open FStar.Real
noeq
type history (a:Type) (p:preorder a) =
| Witnessed : hist p -> history a p
| Current : h:vhist p -> f:perm -> history a p
let hval_tot #a #p (h:history a p{Current? h}) : a =
match h with
| Current h _ -> curval h
let hval #a #p (h:history a p{Current? h}) : Ghost.erased a =
hval_tot h
let hperm #a #p (h:history a p{Current? h}) : perm =
match h with
| Current _ f -> f
let history_composable #a #p
: symrel (history a p)
= fun h0 h1 ->
match h0, h1 with
| Witnessed h0, Witnessed h1 ->
p_composable p h0 h1
| Witnessed h0, Current h1 f
| Current h1 f, Witnessed h0 ->
extends #a #p h1 h0
| Current h0 f0, Current h1 f1 ->
h0 == h1 /\
(sum_perm f0 f1).v <=. one
let history_compose #a #p (h0:history a p) (h1:history a p{history_composable h0 h1})
: history a p
= match h0, h1 with
| Witnessed h0, Witnessed h1 ->
Witnessed (p_op p h0 h1)
| Current h0 f, Witnessed h1
| Witnessed h1, Current h0 f ->
Current (p_op p h1 h0) f
| Current h0 f0, Current _ f1 ->
Current h0 (sum_perm f0 f1)
let unit_history #a #p : history a p = Witnessed []
let lem_is_unit #a #p (x:history a p)
: Lemma (history_composable x unit_history /\
history_compose x unit_history == x)
= match x with
| Witnessed h -> ()
| Current h _ ->
assert (forall (h:hist p). p_composable p h []);
assert (forall (h:hist p). p_op p h [] == h);
assert (forall (h:vhist p). extends #a #p h []);
assert (h =!= []);
assert (extends #a #p h [])
#push-options "--z3rlimit_factor 2"
let assoc_l #a #p (x y:history a p)
(z:history a p{history_composable y z /\
history_composable x (history_compose y z)})
: Lemma (history_composable x y /\
history_composable (history_compose x y) z /\
history_compose (history_compose x y) z ==
history_compose x (history_compose y z))
= ()
let assoc_r #a #p (x y:history a p)
(z:history a p{history_composable x y /\
history_composable (history_compose x y) z})
: Lemma (history_composable y z /\
history_composable x (history_compose y z) /\
history_compose (history_compose x y) z ==
history_compose x (history_compose y z))
= ()
#pop-options
let pcm_history #a #p : pcm (history a p) = {
p = {
composable = history_composable;
op = history_compose;
one = unit_history
};
comm = (fun _ _ -> ());
assoc = assoc_l;
assoc_r = assoc_r;
is_unit = lem_is_unit;
refine = (fun _ -> True);
}
let pcm_history_preorder #a #p : preorder (history a p) =
fun h0 h1 ->
match h0, h1 with
| Witnessed vh0, Witnessed vh1
| Current vh0 _, Witnessed vh1
| Witnessed vh0, Current vh1 _
| Current vh0 _, Current vh1 _ ->
vh1 `extends` vh0 | {
"checked_file": "/",
"dependencies": [
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Real.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.IndefiniteDescription.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Preorder.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Real",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Preorder",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"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": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 8,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Pervasives.Lemma
(ensures
Steel.Preorder.induces_preorder Steel.Preorder.pcm_history Steel.Preorder.pcm_history_preorder) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Preorder.preorder",
"Steel.Preorder.history",
"FStar.PCM.frame_preserving_upd",
"Steel.Preorder.pcm_history",
"Prims.unit",
"FStar.PCM.compatible",
"Prims.squash",
"Steel.Preorder.pcm_history_preorder",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil",
"FStar.Pervasives.Native.Mktuple3",
"Steel.Preorder.hist",
"Prims._assert",
"FStar.PCM.composable",
"Steel.Preorder.vhist",
"Steel.FractionalPermission.perm",
"Steel.Preorder.Witnessed",
"Prims.eq2",
"Steel.Preorder.extends",
"Prims.l_and",
"FStar.PCM.op",
"FStar.IndefiniteDescription.indefinite_description_ghost",
"Prims.prop",
"FStar.PCM.__proj__Mkpcm__item__refine",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.PCM.pcm",
"Prims.l_True",
"Steel.Preorder.induces_preorder"
] | [] | false | false | true | false | false | let pcm_history_induces_preorder #a #p
: Lemma (induces_preorder (pcm_history #a #p) (pcm_history_preorder #a #p)) =
| let aux (x y: history a p) (f: frame_preserving_upd (pcm_history #a #p) x y) (v: history a p)
: Lemma (requires compatible (pcm_history #a #p) x v)
(ensures (pcm_history_preorder #a #p) v (f v))
[SMTPat ()] =
let pcm = pcm_history #a #p in
let v1 = f v in
match x, v, v1 with
| Witnessed _, Witnessed _, Witnessed _ -> assert (composable pcm x v)
| Current _ _, Witnessed _, Witnessed _ -> ()
| Witnessed _, Current _ _, Witnessed _ -> ()
| Witnessed _, Witnessed _, Current _ _ -> assert (composable pcm x v)
| Current _ _, Witnessed _, Current _ _ -> ()
| Witnessed _, Current _ _, Current _ _ -> ()
| Current hx _, Current hv _, Witnessed _
| Current hx _, Current hv _, Current _ _ ->
let frame =
FStar.IndefiniteDescription.indefinite_description_ghost (history a p)
(fun frame -> composable pcm x frame /\ op pcm frame x == v)
in
match frame with
| Current hf _ -> ()
| Witnessed hf ->
assert (extends hx hf);
assert (hx == hv);
assert (composable pcm x (Witnessed hv))
in
() | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.k_w | val k_w : a: Spec.Hash.Definitions.sha2_alg -> Type0 | let k_w (a: sha2_alg) = lseq (word a) (block_word_length a) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 61,
"end_line": 48,
"start_col": 0,
"start_line": 48
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5 | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Lib.Sequence.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.block_word_length"
] | [] | false | false | false | true | true | let k_w (a: sha2_alg) =
| lseq (word a) (block_word_length a) | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.op0 | val op0 (a: sha2_alg) : Tot ops | val op0 (a: sha2_alg) : Tot ops | let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512 | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 81,
"start_col": 0,
"start_line": 77
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
} | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> Hacl.Spec.SHA2.ops | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.op224_256",
"Hacl.Spec.SHA2.op384_512",
"Hacl.Spec.SHA2.ops"
] | [] | false | false | false | true | false | let op0: a: sha2_alg -> Tot ops =
| function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512 | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.mk_len_t | val mk_len_t (a: sha2_alg) (len: len_lt_max_a_t a) : len_t a | val mk_len_t (a: sha2_alg) (len: len_lt_max_a_t a) : len_t a | let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 61,
"end_line": 20,
"start_col": 0,
"start_line": 15
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a} | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> len: Hacl.Spec.SHA2.len_lt_max_a_t a
-> Spec.Hash.Definitions.len_t a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.len_lt_max_a_t",
"Lib.IntTypes.uint",
"Lib.IntTypes.U64",
"Lib.IntTypes.PUB",
"Prims.unit",
"FStar.Math.Lemmas.pow2_lt_compat",
"Lib.IntTypes.U128",
"Spec.Hash.Definitions.len_t"
] | [] | false | false | false | false | false | let mk_len_t (a: sha2_alg) (len: len_lt_max_a_t a) : len_t a =
| match a with
| SHA2_224
| SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61;
uint #U64 #PUB len)
| SHA2_384
| SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125;
uint #U128 #PUB len) | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.ws_next | val ws_next (a: sha2_alg) (ws: k_w a) : k_w a | val ws_next (a: sha2_alg) (ws: k_w a) : k_w a | let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 193,
"start_col": 0,
"start_line": 192
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16) | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> ws: Hacl.Spec.SHA2.k_w a -> Hacl.Spec.SHA2.k_w a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.k_w",
"Lib.LoopCombinators.repeati",
"Hacl.Spec.SHA2.ws_next_inner"
] | [] | false | false | false | false | false | let ws_next (a: sha2_alg) (ws: k_w a) : k_w a =
| Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.init | val init (a: sha2_alg) : words_state a | val init (a: sha2_alg) : words_state a | let init (a:sha2_alg) : words_state a = h0 a | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 44,
"end_line": 228,
"start_col": 0,
"start_line": 228
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> Spec.Hash.Definitions.words_state a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.h0",
"Spec.Hash.Definitions.words_state"
] | [] | false | false | false | false | false | let init (a: sha2_alg) : words_state a =
| h0 a | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.shuffle_inner_loop | val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a | val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a | let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st') | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 219,
"start_col": 0,
"start_line": 216
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
i: Prims.nat{i < Hacl.Spec.SHA2.num_rounds16 a} ->
ws_st: (Hacl.Spec.SHA2.k_w a * Spec.Hash.Definitions.words_state a)
-> Hacl.Spec.SHA2.k_w a * Spec.Hash.Definitions.words_state a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.SHA2.num_rounds16",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.SHA2.k_w",
"Spec.Hash.Definitions.words_state",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_Subtraction",
"Hacl.Spec.SHA2.ws_next",
"Prims.bool",
"Lib.LoopCombinators.repeati",
"Hacl.Spec.SHA2.shuffle_inner"
] | [] | false | false | false | false | false | let shuffle_inner_loop a i (ws, st) =
| let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st') | false |
Hacl.Spec.Curve25519.Field64.Lemmas.fst | Hacl.Spec.Curve25519.Field64.Lemmas.lemma_prime | val lemma_prime: unit -> Lemma (pow2 256 % prime == 38) | val lemma_prime: unit -> Lemma (pow2 256 % prime == 38) | let lemma_prime () =
calc (==) {
pow2 256 % prime;
(==) { Math.Lemmas.pow2_plus 255 1 }
2 * pow2 255 % prime;
(==) { Math.Lemmas.lemma_mod_mul_distr_r 2 (pow2 255) prime }
2 * (pow2 255 % prime) % prime;
(==) { Math.Lemmas.sub_div_mod_1 (pow2 255) prime }
2 * (19 % prime) % prime;
(==) { Math.Lemmas.lemma_mod_mul_distr_r 2 19 prime }
38 % prime;
(==) { Math.Lemmas.small_mod 38 prime }
38;
} | {
"file_name": "code/curve25519/Hacl.Spec.Curve25519.Field64.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 31,
"start_col": 0,
"start_line": 18
} | module Hacl.Spec.Curve25519.Field64.Lemmas
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Spec.Curve25519
open Hacl.Spec.Curve25519.Field64.Definition
module BSeq = Lib.ByteSequence
module SD = Hacl.Spec.Bignum.Definitions
module SL = Hacl.Spec.Bignum.Lib
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Bignum.Lib.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Convert.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Curve25519.Field64.Lemmas.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Lib",
"short_module": "SL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field64.Definition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Curve25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Curve25519.Field64",
"short_module": null
},
{
"abbrev": 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 | _: Prims.unit -> FStar.Pervasives.Lemma (ensures Prims.pow2 256 % Spec.Curve25519.prime == 38) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Modulus",
"Prims.pow2",
"Spec.Curve25519.prime",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Mul.op_Star",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.pow2_plus",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_mul_distr_r",
"FStar.Math.Lemmas.sub_div_mod_1",
"FStar.Math.Lemmas.small_mod"
] | [] | false | false | true | false | false | let lemma_prime () =
| calc ( == ) {
pow2 256 % prime;
( == ) { Math.Lemmas.pow2_plus 255 1 }
2 * pow2 255 % prime;
( == ) { Math.Lemmas.lemma_mod_mul_distr_r 2 (pow2 255) prime }
2 * (pow2 255 % prime) % prime;
( == ) { Math.Lemmas.sub_div_mod_1 (pow2 255) prime }
2 * (19 % prime) % prime;
( == ) { Math.Lemmas.lemma_mod_mul_distr_r 2 19 prime }
38 % prime;
( == ) { Math.Lemmas.small_mod 38 prime }
38;
} | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2._Sigma0 | val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a) | val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a) | let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 83,
"end_line": 131,
"start_col": 0,
"start_line": 131
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> x: Spec.Hash.Definitions.word a -> Spec.Hash.Definitions.word a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.word",
"Hacl.Spec.SHA2.op_Hat_Dot",
"Hacl.Spec.SHA2.op_Greater_Greater_Greater_Dot",
"Hacl.Spec.SHA2.__proj__Mkops__item__c0",
"Hacl.Spec.SHA2.op0",
"Hacl.Spec.SHA2.__proj__Mkops__item__c1",
"Hacl.Spec.SHA2.__proj__Mkops__item__c2"
] | [] | false | false | false | false | false | let _Sigma0 a x =
| (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2) | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_first_cmp_opr | val print_first_cmp_opr : o: Vale.PPC64LE.Machine_s.cmp_opr -> p: Vale.PPC64LE.Print_s.printer -> Prims.string | let print_first_cmp_opr (o:cmp_opr) (p:printer) =
match o with
| CReg r -> print_reg r p
| _ -> "!!! INVALID first compare operand !!! Expected general purpose register." | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 83,
"end_line": 47,
"start_col": 0,
"start_line": 44
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v
let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p)
let cmp_not(o:ocmp) : ocmp =
match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2
// Sanity check
let _ = assert (forall o . o == cmp_not (cmp_not o)) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | o: Vale.PPC64LE.Machine_s.cmp_opr -> p: Vale.PPC64LE.Print_s.printer -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Machine_s.cmp_opr",
"Vale.PPC64LE.Print_s.printer",
"Vale.PPC64LE.Machine_s.reg",
"Vale.PPC64LE.Print_s.print_reg",
"Prims.string"
] | [] | false | false | false | true | false | let print_first_cmp_opr (o: cmp_opr) (p: printer) =
| match o with
| CReg r -> print_reg r p
| _ -> "!!! INVALID first compare operand !!! Expected general purpose register." | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.k0 | val k0 (a: sha2_alg) : Tot (m: S.seq (word a) {S.length m = size_k_w a}) | val k0 (a: sha2_alg) : Tot (m: S.seq (word a) {S.length m = size_k_w a}) | let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512 | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 155,
"start_col": 0,
"start_line": 151
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512 | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg
-> m:
FStar.Seq.Base.seq (Spec.Hash.Definitions.word a)
{FStar.Seq.Base.length m = Hacl.Spec.SHA2.size_k_w a} | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.Constants.k224_256",
"Spec.SHA2.Constants.k384_512",
"FStar.Seq.Base.seq",
"Spec.Hash.Definitions.word",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.SHA2.size_k_w"
] | [] | false | false | false | false | false | let k0: a: sha2_alg -> Tot (m: S.seq (word a) {S.length m = size_k_w a}) =
| function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512 | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_reg | val print_reg : r: Vale.PPC64LE.Machine_s.reg -> p: Vale.PPC64LE.Print_s.printer -> Prims.string | let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 23,
"start_col": 0,
"start_line": 22
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
} | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: Vale.PPC64LE.Machine_s.reg -> p: Vale.PPC64LE.Print_s.printer -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Machine_s.reg",
"Vale.PPC64LE.Print_s.printer",
"Prims.op_Hat",
"Vale.PPC64LE.Print_s.__proj__Mkprinter__item__reg_prefix",
"Prims.string_of_int",
"Prims.string"
] | [] | false | false | false | true | false | let print_reg (r: reg) (p: printer) =
| p.reg_prefix () ^ string_of_int r | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.shuffle | val shuffle (a: sha2_alg) (ws: k_w a) (hash: words_state a) : Tot (words_state a) | val shuffle (a: sha2_alg) (ws: k_w a) (hash: words_state a) : Tot (words_state a) | let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 225,
"start_col": 0,
"start_line": 223
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *) | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
ws: Hacl.Spec.SHA2.k_w a ->
hash: Spec.Hash.Definitions.words_state a
-> Spec.Hash.Definitions.words_state a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.k_w",
"Spec.Hash.Definitions.words_state",
"FStar.Pervasives.Native.tuple2",
"Lib.LoopCombinators.repeati",
"Hacl.Spec.SHA2.num_rounds16",
"Hacl.Spec.SHA2.shuffle_inner_loop",
"FStar.Pervasives.Native.Mktuple2"
] | [] | false | false | false | false | false | let shuffle (a: sha2_alg) (ws: k_w a) (hash: words_state a) : Tot (words_state a) =
| let ws, st = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_vec | val print_vec : v: Vale.PPC64LE.Machine_s.vec -> vsr: Prims.bool -> p: Vale.PPC64LE.Print_s.printer -> Prims.string | let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 39,
"end_line": 27,
"start_col": 0,
"start_line": 25
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | v: Vale.PPC64LE.Machine_s.vec -> vsr: Prims.bool -> p: Vale.PPC64LE.Print_s.printer -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Machine_s.vec",
"Prims.bool",
"Vale.PPC64LE.Print_s.printer",
"Prims.op_Hat",
"Vale.PPC64LE.Print_s.__proj__Mkprinter__item__vsr_prefix",
"Prims.string_of_int",
"Vale.PPC64LE.Print_s.__proj__Mkprinter__item__vec_prefix",
"Prims.string"
] | [] | false | false | false | true | false | let print_vec (v: vec) (vsr: bool) (p: printer) =
| if vsr then p.vsr_prefix () ^ "32+" ^ string_of_int v else p.vec_prefix () ^ string_of_int v | false |
|
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_maddr | val print_maddr : m: Vale.PPC64LE.Machine_s.maddr -> p: Vale.PPC64LE.Print_s.printer -> Prims.string | let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p) | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 58,
"end_line": 30,
"start_col": 0,
"start_line": 29
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | m: Vale.PPC64LE.Machine_s.maddr -> p: Vale.PPC64LE.Print_s.printer -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Machine_s.maddr",
"Vale.PPC64LE.Print_s.printer",
"Vale.PPC64LE.Print_s.__proj__Mkprinter__item__maddr",
"Prims.string_of_int",
"Vale.PPC64LE.Machine_s.__proj__Mkmaddr__item__offset",
"Vale.PPC64LE.Print_s.print_reg",
"Vale.PPC64LE.Machine_s.__proj__Mkmaddr__item__address",
"Prims.string"
] | [] | false | false | false | true | false | let print_maddr (m: maddr) (p: printer) =
| p.maddr (string_of_int m.offset) (print_reg m.address p) | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.shuffle_inner | val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a | val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a | let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 207,
"start_col": 0,
"start_line": 204
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
ws: Hacl.Spec.SHA2.k_w a ->
i: Prims.nat{i < Hacl.Spec.SHA2.num_rounds16 a} ->
j: Prims.nat{j < 16} ->
hash: Spec.Hash.Definitions.words_state a
-> Spec.Hash.Definitions.words_state a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.k_w",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.SHA2.num_rounds16",
"Spec.Hash.Definitions.words_state",
"Hacl.Spec.SHA2.shuffle_core_pre",
"Spec.Hash.Definitions.word",
"Hacl.Spec.SHA2.op_String_Access",
"FStar.Seq.Base.index",
"Hacl.Spec.SHA2.k0",
"Prims.op_Addition",
"FStar.Mul.op_Star"
] | [] | false | false | false | false | false | let shuffle_inner a ws i j hash =
| let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[ j ] in
shuffle_core_pre a k_t ws_t hash | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.h0 | val h0 (a: sha2_alg) : Tot (words_state a) | val h0 (a: sha2_alg) : Tot (words_state a) | let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512 | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 149,
"start_col": 0,
"start_line": 145
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5) | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> Spec.Hash.Definitions.words_state a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.Constants.h224",
"Spec.SHA2.Constants.h256",
"Spec.SHA2.Constants.h384",
"Spec.SHA2.Constants.h512",
"Spec.Hash.Definitions.words_state"
] | [] | false | false | false | false | false | let h0: a: sha2_alg -> Tot (words_state a) =
| function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512 | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2._Sigma1 | val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a) | val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a) | let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 83,
"end_line": 135,
"start_col": 0,
"start_line": 135
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> x: Spec.Hash.Definitions.word a -> Spec.Hash.Definitions.word a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.word",
"Hacl.Spec.SHA2.op_Hat_Dot",
"Hacl.Spec.SHA2.op_Greater_Greater_Greater_Dot",
"Hacl.Spec.SHA2.__proj__Mkops__item__c3",
"Hacl.Spec.SHA2.op0",
"Hacl.Spec.SHA2.__proj__Mkops__item__c4",
"Hacl.Spec.SHA2.__proj__Mkops__item__c5"
] | [] | false | false | false | false | false | let _Sigma1 a x =
| (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5) | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2._sigma0 | val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a) | val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a) | let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 82,
"end_line": 139,
"start_col": 0,
"start_line": 139
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> x: Spec.Hash.Definitions.word a -> Spec.Hash.Definitions.word a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.word",
"Hacl.Spec.SHA2.op_Hat_Dot",
"Hacl.Spec.SHA2.op_Greater_Greater_Greater_Dot",
"Hacl.Spec.SHA2.__proj__Mkops__item__e0",
"Hacl.Spec.SHA2.op0",
"Hacl.Spec.SHA2.__proj__Mkops__item__e1",
"Hacl.Spec.SHA2.op_Greater_Greater_Dot",
"Hacl.Spec.SHA2.__proj__Mkops__item__e2"
] | [] | false | false | false | false | false | let _sigma0 a x =
| (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2) | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.ws_next_inner | val ws_next_inner (a: sha2_alg) (i: nat{i < 16}) (ws: k_w a) : k_w a | val ws_next_inner (a: sha2_alg) (i: nat{i < 16}) (ws: k_w a) : k_w a | let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 190,
"start_col": 0,
"start_line": 183
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *) | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> i: Prims.nat{i < 16} -> ws: Hacl.Spec.SHA2.k_w a
-> Hacl.Spec.SHA2.k_w a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.SHA2.k_w",
"FStar.Seq.Base.upd",
"Spec.Hash.Definitions.word",
"Hacl.Spec.SHA2.op_Plus_Dot",
"Hacl.Spec.SHA2._sigma0",
"Hacl.Spec.SHA2._sigma1",
"Hacl.Spec.SHA2.op_String_Access",
"Prims.op_Modulus",
"Prims.op_Addition"
] | [] | false | false | false | false | false | let ws_next_inner (a: sha2_alg) (i: nat{i < 16}) (ws: k_w a) : k_w a =
| let t16 = ws.[ i ] in
let t15 = ws.[ (i + 1) % 16 ] in
let t7 = ws.[ (i + 9) % 16 ] in
let t2 = ws.[ (i + 14) % 16 ] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16) | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.gcc | val gcc:printer | val gcc:printer | let gcc : printer =
let reg_prefix unit = "" in
let vec_prefix unit = "" in
let vsr_prefix unit = "" in
let maddr (offset:string) (address:string) =
offset ^ "(" ^ address ^ ")"
in
let const (n:int) = string_of_int n in
let align() = ".align" in
let header() = ".text\n" in
let footer() = ".section .note.GNU-stack,\"\",%progbits\n" in
let proc_name (name:string) = ".global " ^ name ^ "\n" ^ name ^ ":\n" in
let branch_link (name:string) = " blr\n\n" in
{
reg_prefix = reg_prefix;
vec_prefix = vec_prefix;
vsr_prefix = vsr_prefix;
maddr = maddr;
const = const;
align = align;
header = header;
footer = footer;
proc_name = proc_name;
ret = branch_link;
} | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 259,
"start_col": 0,
"start_line": 235
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v
let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p)
let cmp_not(o:ocmp) : ocmp =
match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2
// Sanity check
let _ = assert (forall o . o == cmp_not (cmp_not o))
let print_first_cmp_opr (o:cmp_opr) (p:printer) =
match o with
| CReg r -> print_reg r p
| _ -> "!!! INVALID first compare operand !!! Expected general purpose register."
let print_ins (ins:ins) (p:printer) =
let print_pair (o1 o2:string) =
o1 ^ ", " ^ o2
in
let print_triple (o1 o2 o3:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3
in
let print_quadruple (o1 o2 o3 o4:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3 ^ ", " ^ o4
in
let print_reg_pair (dst src:reg) =
print_pair (print_reg dst p) (print_reg src p)
in
let print_reg_mem (o1:reg) (o2:maddr) =
print_pair (print_reg o1 p) (print_maddr o2 p)
in
let print_reg_triple (dst src1 src2:reg) =
print_triple (print_reg dst p) (print_reg src1 p) (print_reg src2 p)
in
let print_reg_imm (dst:reg) (src:int) =
print_pair (print_reg dst p) (p.const src)
in
let print_reg_pair_imm (dst src1:reg) (src2:int) =
print_triple (print_reg dst p) (print_reg src1 p) (p.const src2)
in
let print_reg_vec (dst:reg) (src:vec) (vsr:bool) =
print_pair (print_reg dst p) (print_vec src vsr p)
in
let print_vec_reg (dst:vec) (src:reg) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_reg src p)
in
let print_vec_reg_pair (dst:vec) (src1 src2:reg) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_reg src1 p) (print_reg src2 p)
in
let print_vec_pair (dst src:vec) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_vec src vsr p)
in
let print_vec_triple (dst src1 src2:vec) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p)
in
let print_vec_quadruple (dst src1 src2 src3:vec) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (print_vec src3 vsr p)
in
let print_vec_imm (dst:vec) (src:int) (vsr:bool) =
print_pair (print_vec dst vsr p) (p.const src)
in
let print_vec_pair_imm (dst src:vec) (imm:int) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src vsr p) (p.const imm)
in
let print_vec_triple_imm (dst src1 src2:vec) (count:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (p.const count)
in
let print_vec_mem (o1:vec) (o2:maddr) (vsr:bool) =
print_pair (print_vec o1 vsr p) (print_maddr o2 p)
in
let print_vec_pair_imm_pair (dst src:vec) (s0 s1:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src vsr p) (p.const s0) (p.const s1)
in
match ins with
| Move dst src -> " mr " ^ print_reg_pair dst src
| Load64 dst base offset -> " ld " ^ print_reg_mem dst ({ address = base; offset = offset })
| Store64 src base offset -> " std " ^ print_reg_mem src ({ address = base; offset = offset })
| LoadImm64 dst src -> " li " ^ print_reg_imm dst src
| LoadImmShl64 dst src -> " lis " ^ print_reg_imm dst src
| AddLa dst src1 src2 -> " la " ^ print_reg_mem dst ({ address = src1; offset = src2 })
| Add dst src1 src2 -> " add " ^ print_reg_triple dst src1 src2
| AddImm dst src1 src2 -> " addi " ^ print_reg_pair_imm dst src1 src2
| AddCarry dst src1 src2 -> " addc " ^ print_reg_triple dst src1 src2
| AddExtended dst src1 src2 -> " adde " ^ print_reg_triple dst src1 src2
| AddExtendedOV dst src1 src2 -> " addex " ^ print_reg_triple dst src1 src2
| Sub dst src1 src2 -> " sub " ^ print_reg_triple dst src1 src2
| SubImm dst src1 src2 -> " subi " ^ print_reg_pair_imm dst src1 src2
| MulLow64 dst src1 src2 -> " mulld " ^ print_reg_triple dst src1 src2
| MulHigh64U dst src1 src2 -> " mulhdu " ^ print_reg_triple dst src1 src2
| Xor dst src1 src2 -> " xor " ^ print_reg_triple dst src1 src2
| And dst src1 src2 -> " and " ^ print_reg_triple dst src1 src2
| Sr64Imm dst src1 src2 -> " srdi " ^ print_reg_pair_imm dst src1 src2
| Sl64Imm dst src1 src2 -> " sldi " ^ print_reg_pair_imm dst src1 src2
| Sr64 dst src1 src2 -> " srd " ^ print_reg_triple dst src1 src2
| Sl64 dst src1 src2 -> " sld " ^ print_reg_triple dst src1 src2
| Vmr dst src -> " vmr " ^ print_vec_pair dst src false
| Mfvsrd dst src -> " mfvsrd " ^ print_reg_vec dst src true
| Mfvsrld dst src -> " mfvsrld " ^ print_reg_vec dst src true
| Mtvsrdd dst src1 src2 -> " mtvsrdd " ^ print_vec_reg_pair dst src1 src2 true
| Mtvsrws dst src -> " mtvsrws " ^ print_vec_reg dst src true
| Vadduwm dst src1 src2 -> " vadduwm " ^ print_vec_triple dst src1 src2 false
| Vxor dst src1 src2 -> " vxor " ^ print_vec_triple dst src1 src2 false
| Vand dst src1 src2 -> " vand " ^ print_vec_triple dst src1 src2 false
| Vslw dst src1 src2 -> " vslw " ^ print_vec_triple dst src1 src2 false
| Vsrw dst src1 src2 -> " vsrw " ^ print_vec_triple dst src1 src2 false
| Vsl dst src1 src2 -> " vsl " ^ print_vec_triple dst src1 src2 false
| Vcmpequw dst src1 src2 -> " vcmpequw " ^ print_vec_triple dst src1 src2 false
| Vsldoi dst src1 src2 count -> " vsldoi " ^ print_vec_triple_imm dst src1 src2 count false
| Vmrghw dst src1 src2 -> " vmrghw " ^ print_vec_triple dst src1 src2 false
| Xxmrghd dst src1 src2 -> " xxmrghd " ^ print_vec_triple dst src1 src2 true
| Vsel dst src1 src2 sel -> " vsel " ^ print_vec_quadruple dst src1 src2 sel false
| Vspltw dst src uim -> " vspltw " ^ print_vec_pair_imm dst src uim false
| Vspltisw dst src -> " vspltisw " ^ print_vec_imm dst src false
| Vspltisb dst src -> " vspltisb " ^ print_vec_imm dst src false
| Load128 dst base offset -> " lvx " ^ print_vec_reg_pair dst offset base false
| Store128 src base offset -> " stvx " ^ print_vec_reg_pair src offset base false
| Load128Word4 dst base -> " lxvw4x " ^ print_vec_reg_pair dst 0 base true
| Load128Word4Index dst base offset -> " lxvw4x " ^ print_vec_reg_pair dst offset base true
| Store128Word4 src base -> " stxvw4x " ^ print_vec_reg_pair src 0 base true
| Store128Word4Index src base offset -> " stxvw4x " ^ print_vec_reg_pair src offset base true
| Load128Byte16 dst base -> " lxvb16x " ^ print_vec_reg_pair dst 0 base true
| Load128Byte16Index dst base offset -> " lxvb16x " ^ print_vec_reg_pair dst offset base true
| Store128Byte16 src base -> " stxvb16x " ^ print_vec_reg_pair src 0 base true
| Store128Byte16Index src base offset -> " stxvb16x " ^ print_vec_reg_pair src offset base true
| Vshasigmaw0 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 0 false
| Vshasigmaw1 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 15 false
| Vshasigmaw2 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 0 false
| Vshasigmaw3 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 15 false
| Vsbox dst src -> " vsbox " ^ print_vec_pair dst src false
| RotWord dst src1 src2 -> " vrlw " ^ print_vec_triple dst src1 src2 false
| Vcipher dst src1 src2 -> " vcipher " ^ print_vec_triple dst src1 src2 false
| Vcipherlast dst src1 src2 -> " vcipherlast " ^ print_vec_triple dst src1 src2 false
| Vncipher dst src1 src2 -> " vncipher " ^ print_vec_triple dst src1 src2 false
| Vncipherlast dst src1 src2 -> " vncipherlast " ^ print_vec_triple dst src1 src2 false
| Vpmsumd dst src1 src2 -> " vpmsumd " ^ print_vec_triple dst src1 src2 false
| Alloc n -> " subi " ^ print_reg_pair_imm 1 1 n
| Dealloc n -> " addi " ^ print_reg_pair_imm 1 1 n
| StoreStack128 src t offset -> " stxv " ^ print_vec_mem src ({ address = 1; offset = offset }) true
| LoadStack128 dst t offset -> " lxv " ^ print_vec_mem dst ({ address = 1; offset = offset }) true
| StoreStack64 src t offset -> " std " ^ print_reg_mem src ({ address = 1; offset = offset })
| LoadStack64 dst t offset -> " ld " ^ print_reg_mem dst ({ address = 1; offset = offset })
| Ghost _ -> ""
let print_cmp (c:ocmp) (counter:int) (p:printer) : string =
let print_cmp_ops (o1:cmp_opr) (o2:cmp_opr) : string =
match o2 with
| CReg r -> " cmpld " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (print_reg r p) ^ "\n"
| CImm n -> " cmpldi " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (string_of_int n) ^ "\n"
in
match c with
| OEq o1 o2 -> print_cmp_ops o1 o2 ^ " beq " ^ "L" ^ string_of_int counter ^ "\n"
| ONe o1 o2 -> print_cmp_ops o1 o2 ^ " bne "^ "L" ^ string_of_int counter ^ "\n"
| OLe o1 o2 -> print_cmp_ops o1 o2 ^ " ble "^ "L" ^ string_of_int counter ^ "\n"
| OGe o1 o2 -> print_cmp_ops o1 o2 ^ " bge "^ "L" ^ string_of_int counter ^ "\n"
| OLt o1 o2 -> print_cmp_ops o1 o2 ^ " blt " ^ "L" ^ string_of_int counter ^ "\n"
| OGt o1 o2 -> print_cmp_ops o1 o2 ^ " bgt " ^ "L" ^ string_of_int counter ^ "\n"
let rec print_block (b:codes) (n:int) (p:printer) : string & int =
match b with
| Nil -> ("", n)
| head :: tail ->
let (head_str, n') = print_code head n p in
let (rest, n'') = print_block tail n' p in
(head_str ^ rest, n'')
and print_code (c:code) (n:int) (p:printer) : string & int =
match c with
| Ins ins -> (print_ins ins p ^ "\n", n)
| Block b -> print_block b n p
| IfElse cond true_code false_code ->
let n1 = n in
let n2 = n + 1 in
let cmp = print_cmp (cmp_not cond) n1 p in
let (true_str, n') = print_code true_code (n + 2) p in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = "L" ^ string_of_int n1 ^ ":\n" in
let (false_str, n') = print_code false_code n' p in
let label2 = "L" ^ string_of_int n2 ^ ":\n" in
(cmp ^ true_str ^ branch ^ label1 ^ false_str ^ label2, n')
| While cond body ->
let n1 = n in
let n2 = n + 1 in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = p.align() ^ " 4\nL" ^ string_of_int n1 ^ ":\n" in
let (body_str, n') = print_code body (n + 2) p in
let label2 = p.align() ^ " 4\nL" ^ string_of_int n2 ^ ":\n" in
let cmp = print_cmp cond n1 p in
(branch ^ label1 ^ body_str ^ label2 ^ cmp, n')
let print_header (p:printer) =
print_string (p.header())
let print_proc (name:string) (code:code) (label:int) (p:printer) : FStar.All.ML int =
let proc = p.proc_name name in
let (code_str, final_label) = print_code code label p in
let ret = p.ret name in
print_string (proc ^ code_str ^ ret);
final_label
let print_footer (p:printer) =
print_string (p.footer()) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Vale.PPC64LE.Print_s.printer | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Print_s.Mkprinter",
"Prims.string",
"Prims.op_Hat",
"Prims.unit",
"Prims.int",
"Prims.string_of_int"
] | [] | false | false | false | true | false | let gcc:printer =
| let reg_prefix unit = "" in
let vec_prefix unit = "" in
let vsr_prefix unit = "" in
let maddr (offset address: string) = offset ^ "(" ^ address ^ ")" in
let const (n: int) = string_of_int n in
let align () = ".align" in
let header () = ".text\n" in
let footer () = ".section .note.GNU-stack,\"\",%progbits\n" in
let proc_name (name: string) = ".global " ^ name ^ "\n" ^ name ^ ":\n" in
let branch_link (name: string) = " blr\n\n" in
{
reg_prefix = reg_prefix;
vec_prefix = vec_prefix;
vsr_prefix = vsr_prefix;
maddr = maddr;
const = const;
align = align;
header = header;
footer = footer;
proc_name = proc_name;
ret = branch_link
} | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.shuffle_core_pre | val shuffle_core_pre (a: sha2_alg) (k_t ws_t: word a) (hash: words_state a) : Tot (words_state a) | val shuffle_core_pre (a: sha2_alg) (k_t ws_t: word a) (hash: words_state a) : Tot (words_state a) | let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 179,
"start_col": 0,
"start_line": 162
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *) | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
k_t: Spec.Hash.Definitions.word a ->
ws_t: Spec.Hash.Definitions.word a ->
hash: Spec.Hash.Definitions.words_state a
-> Spec.Hash.Definitions.words_state a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.words_state",
"FStar.Seq.Base.seq_of_list",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"Prims.Cons",
"Hacl.Spec.SHA2.op_Plus_Dot",
"Prims.Nil",
"Hacl.Spec.SHA2._Sigma0",
"Hacl.Spec.SHA2._Maj",
"Hacl.Spec.SHA2._Sigma1",
"Hacl.Spec.SHA2._Ch",
"Prims._assert",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.SHA2.k0",
"Hacl.Spec.SHA2.size_k_w",
"Hacl.Spec.SHA2.op_String_Access",
"Prims.op_LessThanOrEqual"
] | [] | false | false | false | false | false | let shuffle_core_pre (a: sha2_alg) (k_t ws_t: word a) (hash: words_state a) : Tot (words_state a) =
| assert (7 <= S.length hash);
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
assert (S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_header | val print_header : p: Vale.PPC64LE.Print_s.printer -> FStar.All.ML Prims.unit | let print_header (p:printer) =
print_string (p.header()) | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 222,
"start_col": 0,
"start_line": 221
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v
let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p)
let cmp_not(o:ocmp) : ocmp =
match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2
// Sanity check
let _ = assert (forall o . o == cmp_not (cmp_not o))
let print_first_cmp_opr (o:cmp_opr) (p:printer) =
match o with
| CReg r -> print_reg r p
| _ -> "!!! INVALID first compare operand !!! Expected general purpose register."
let print_ins (ins:ins) (p:printer) =
let print_pair (o1 o2:string) =
o1 ^ ", " ^ o2
in
let print_triple (o1 o2 o3:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3
in
let print_quadruple (o1 o2 o3 o4:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3 ^ ", " ^ o4
in
let print_reg_pair (dst src:reg) =
print_pair (print_reg dst p) (print_reg src p)
in
let print_reg_mem (o1:reg) (o2:maddr) =
print_pair (print_reg o1 p) (print_maddr o2 p)
in
let print_reg_triple (dst src1 src2:reg) =
print_triple (print_reg dst p) (print_reg src1 p) (print_reg src2 p)
in
let print_reg_imm (dst:reg) (src:int) =
print_pair (print_reg dst p) (p.const src)
in
let print_reg_pair_imm (dst src1:reg) (src2:int) =
print_triple (print_reg dst p) (print_reg src1 p) (p.const src2)
in
let print_reg_vec (dst:reg) (src:vec) (vsr:bool) =
print_pair (print_reg dst p) (print_vec src vsr p)
in
let print_vec_reg (dst:vec) (src:reg) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_reg src p)
in
let print_vec_reg_pair (dst:vec) (src1 src2:reg) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_reg src1 p) (print_reg src2 p)
in
let print_vec_pair (dst src:vec) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_vec src vsr p)
in
let print_vec_triple (dst src1 src2:vec) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p)
in
let print_vec_quadruple (dst src1 src2 src3:vec) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (print_vec src3 vsr p)
in
let print_vec_imm (dst:vec) (src:int) (vsr:bool) =
print_pair (print_vec dst vsr p) (p.const src)
in
let print_vec_pair_imm (dst src:vec) (imm:int) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src vsr p) (p.const imm)
in
let print_vec_triple_imm (dst src1 src2:vec) (count:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (p.const count)
in
let print_vec_mem (o1:vec) (o2:maddr) (vsr:bool) =
print_pair (print_vec o1 vsr p) (print_maddr o2 p)
in
let print_vec_pair_imm_pair (dst src:vec) (s0 s1:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src vsr p) (p.const s0) (p.const s1)
in
match ins with
| Move dst src -> " mr " ^ print_reg_pair dst src
| Load64 dst base offset -> " ld " ^ print_reg_mem dst ({ address = base; offset = offset })
| Store64 src base offset -> " std " ^ print_reg_mem src ({ address = base; offset = offset })
| LoadImm64 dst src -> " li " ^ print_reg_imm dst src
| LoadImmShl64 dst src -> " lis " ^ print_reg_imm dst src
| AddLa dst src1 src2 -> " la " ^ print_reg_mem dst ({ address = src1; offset = src2 })
| Add dst src1 src2 -> " add " ^ print_reg_triple dst src1 src2
| AddImm dst src1 src2 -> " addi " ^ print_reg_pair_imm dst src1 src2
| AddCarry dst src1 src2 -> " addc " ^ print_reg_triple dst src1 src2
| AddExtended dst src1 src2 -> " adde " ^ print_reg_triple dst src1 src2
| AddExtendedOV dst src1 src2 -> " addex " ^ print_reg_triple dst src1 src2
| Sub dst src1 src2 -> " sub " ^ print_reg_triple dst src1 src2
| SubImm dst src1 src2 -> " subi " ^ print_reg_pair_imm dst src1 src2
| MulLow64 dst src1 src2 -> " mulld " ^ print_reg_triple dst src1 src2
| MulHigh64U dst src1 src2 -> " mulhdu " ^ print_reg_triple dst src1 src2
| Xor dst src1 src2 -> " xor " ^ print_reg_triple dst src1 src2
| And dst src1 src2 -> " and " ^ print_reg_triple dst src1 src2
| Sr64Imm dst src1 src2 -> " srdi " ^ print_reg_pair_imm dst src1 src2
| Sl64Imm dst src1 src2 -> " sldi " ^ print_reg_pair_imm dst src1 src2
| Sr64 dst src1 src2 -> " srd " ^ print_reg_triple dst src1 src2
| Sl64 dst src1 src2 -> " sld " ^ print_reg_triple dst src1 src2
| Vmr dst src -> " vmr " ^ print_vec_pair dst src false
| Mfvsrd dst src -> " mfvsrd " ^ print_reg_vec dst src true
| Mfvsrld dst src -> " mfvsrld " ^ print_reg_vec dst src true
| Mtvsrdd dst src1 src2 -> " mtvsrdd " ^ print_vec_reg_pair dst src1 src2 true
| Mtvsrws dst src -> " mtvsrws " ^ print_vec_reg dst src true
| Vadduwm dst src1 src2 -> " vadduwm " ^ print_vec_triple dst src1 src2 false
| Vxor dst src1 src2 -> " vxor " ^ print_vec_triple dst src1 src2 false
| Vand dst src1 src2 -> " vand " ^ print_vec_triple dst src1 src2 false
| Vslw dst src1 src2 -> " vslw " ^ print_vec_triple dst src1 src2 false
| Vsrw dst src1 src2 -> " vsrw " ^ print_vec_triple dst src1 src2 false
| Vsl dst src1 src2 -> " vsl " ^ print_vec_triple dst src1 src2 false
| Vcmpequw dst src1 src2 -> " vcmpequw " ^ print_vec_triple dst src1 src2 false
| Vsldoi dst src1 src2 count -> " vsldoi " ^ print_vec_triple_imm dst src1 src2 count false
| Vmrghw dst src1 src2 -> " vmrghw " ^ print_vec_triple dst src1 src2 false
| Xxmrghd dst src1 src2 -> " xxmrghd " ^ print_vec_triple dst src1 src2 true
| Vsel dst src1 src2 sel -> " vsel " ^ print_vec_quadruple dst src1 src2 sel false
| Vspltw dst src uim -> " vspltw " ^ print_vec_pair_imm dst src uim false
| Vspltisw dst src -> " vspltisw " ^ print_vec_imm dst src false
| Vspltisb dst src -> " vspltisb " ^ print_vec_imm dst src false
| Load128 dst base offset -> " lvx " ^ print_vec_reg_pair dst offset base false
| Store128 src base offset -> " stvx " ^ print_vec_reg_pair src offset base false
| Load128Word4 dst base -> " lxvw4x " ^ print_vec_reg_pair dst 0 base true
| Load128Word4Index dst base offset -> " lxvw4x " ^ print_vec_reg_pair dst offset base true
| Store128Word4 src base -> " stxvw4x " ^ print_vec_reg_pair src 0 base true
| Store128Word4Index src base offset -> " stxvw4x " ^ print_vec_reg_pair src offset base true
| Load128Byte16 dst base -> " lxvb16x " ^ print_vec_reg_pair dst 0 base true
| Load128Byte16Index dst base offset -> " lxvb16x " ^ print_vec_reg_pair dst offset base true
| Store128Byte16 src base -> " stxvb16x " ^ print_vec_reg_pair src 0 base true
| Store128Byte16Index src base offset -> " stxvb16x " ^ print_vec_reg_pair src offset base true
| Vshasigmaw0 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 0 false
| Vshasigmaw1 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 15 false
| Vshasigmaw2 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 0 false
| Vshasigmaw3 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 15 false
| Vsbox dst src -> " vsbox " ^ print_vec_pair dst src false
| RotWord dst src1 src2 -> " vrlw " ^ print_vec_triple dst src1 src2 false
| Vcipher dst src1 src2 -> " vcipher " ^ print_vec_triple dst src1 src2 false
| Vcipherlast dst src1 src2 -> " vcipherlast " ^ print_vec_triple dst src1 src2 false
| Vncipher dst src1 src2 -> " vncipher " ^ print_vec_triple dst src1 src2 false
| Vncipherlast dst src1 src2 -> " vncipherlast " ^ print_vec_triple dst src1 src2 false
| Vpmsumd dst src1 src2 -> " vpmsumd " ^ print_vec_triple dst src1 src2 false
| Alloc n -> " subi " ^ print_reg_pair_imm 1 1 n
| Dealloc n -> " addi " ^ print_reg_pair_imm 1 1 n
| StoreStack128 src t offset -> " stxv " ^ print_vec_mem src ({ address = 1; offset = offset }) true
| LoadStack128 dst t offset -> " lxv " ^ print_vec_mem dst ({ address = 1; offset = offset }) true
| StoreStack64 src t offset -> " std " ^ print_reg_mem src ({ address = 1; offset = offset })
| LoadStack64 dst t offset -> " ld " ^ print_reg_mem dst ({ address = 1; offset = offset })
| Ghost _ -> ""
let print_cmp (c:ocmp) (counter:int) (p:printer) : string =
let print_cmp_ops (o1:cmp_opr) (o2:cmp_opr) : string =
match o2 with
| CReg r -> " cmpld " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (print_reg r p) ^ "\n"
| CImm n -> " cmpldi " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (string_of_int n) ^ "\n"
in
match c with
| OEq o1 o2 -> print_cmp_ops o1 o2 ^ " beq " ^ "L" ^ string_of_int counter ^ "\n"
| ONe o1 o2 -> print_cmp_ops o1 o2 ^ " bne "^ "L" ^ string_of_int counter ^ "\n"
| OLe o1 o2 -> print_cmp_ops o1 o2 ^ " ble "^ "L" ^ string_of_int counter ^ "\n"
| OGe o1 o2 -> print_cmp_ops o1 o2 ^ " bge "^ "L" ^ string_of_int counter ^ "\n"
| OLt o1 o2 -> print_cmp_ops o1 o2 ^ " blt " ^ "L" ^ string_of_int counter ^ "\n"
| OGt o1 o2 -> print_cmp_ops o1 o2 ^ " bgt " ^ "L" ^ string_of_int counter ^ "\n"
let rec print_block (b:codes) (n:int) (p:printer) : string & int =
match b with
| Nil -> ("", n)
| head :: tail ->
let (head_str, n') = print_code head n p in
let (rest, n'') = print_block tail n' p in
(head_str ^ rest, n'')
and print_code (c:code) (n:int) (p:printer) : string & int =
match c with
| Ins ins -> (print_ins ins p ^ "\n", n)
| Block b -> print_block b n p
| IfElse cond true_code false_code ->
let n1 = n in
let n2 = n + 1 in
let cmp = print_cmp (cmp_not cond) n1 p in
let (true_str, n') = print_code true_code (n + 2) p in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = "L" ^ string_of_int n1 ^ ":\n" in
let (false_str, n') = print_code false_code n' p in
let label2 = "L" ^ string_of_int n2 ^ ":\n" in
(cmp ^ true_str ^ branch ^ label1 ^ false_str ^ label2, n')
| While cond body ->
let n1 = n in
let n2 = n + 1 in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = p.align() ^ " 4\nL" ^ string_of_int n1 ^ ":\n" in
let (body_str, n') = print_code body (n + 2) p in
let label2 = p.align() ^ " 4\nL" ^ string_of_int n2 ^ ":\n" in
let cmp = print_cmp cond n1 p in
(branch ^ label1 ^ body_str ^ label2 ^ cmp, n') | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Vale.PPC64LE.Print_s.printer -> FStar.All.ML Prims.unit | FStar.All.ML | [
"ml"
] | [] | [
"Vale.PPC64LE.Print_s.printer",
"FStar.IO.print_string",
"Vale.PPC64LE.Print_s.__proj__Mkprinter__item__header",
"Prims.unit"
] | [] | false | true | false | false | false | let print_header (p: printer) =
| print_string (p.header ()) | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.update | val update (a: sha2_alg) (block: block_t a) (hash: words_state a) : Tot (words_state a) | val update (a: sha2_alg) (block: block_t a) (hash: words_state a) : Tot (words_state a) | let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 37,
"end_line": 233,
"start_col": 0,
"start_line": 230
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
block: Hacl.Spec.SHA2.block_t a ->
hash: Spec.Hash.Definitions.words_state a
-> Spec.Hash.Definitions.words_state a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.block_t",
"Spec.Hash.Definitions.words_state",
"Lib.Sequence.map2",
"Spec.Hash.Definitions.word",
"Hacl.Spec.SHA2.op_Plus_Dot",
"Hacl.Spec.SHA2.shuffle",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Spec.Hash.Definitions.word_t",
"Lib.IntTypes.SEC",
"Spec.Hash.Definitions.block_word_length",
"Lib.ByteSequence.uints_from_bytes_be"
] | [] | false | false | false | false | false | let update (a: sha2_alg) (block: block_t a) (hash: words_state a) : Tot (words_state a) =
| let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_proc | val print_proc (name: string) (code: code) (label: int) (p: printer) : FStar.All.ML int | val print_proc (name: string) (code: code) (label: int) (p: printer) : FStar.All.ML int | let print_proc (name:string) (code:code) (label:int) (p:printer) : FStar.All.ML int =
let proc = p.proc_name name in
let (code_str, final_label) = print_code code label p in
let ret = p.ret name in
print_string (proc ^ code_str ^ ret);
final_label | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 229,
"start_col": 0,
"start_line": 224
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v
let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p)
let cmp_not(o:ocmp) : ocmp =
match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2
// Sanity check
let _ = assert (forall o . o == cmp_not (cmp_not o))
let print_first_cmp_opr (o:cmp_opr) (p:printer) =
match o with
| CReg r -> print_reg r p
| _ -> "!!! INVALID first compare operand !!! Expected general purpose register."
let print_ins (ins:ins) (p:printer) =
let print_pair (o1 o2:string) =
o1 ^ ", " ^ o2
in
let print_triple (o1 o2 o3:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3
in
let print_quadruple (o1 o2 o3 o4:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3 ^ ", " ^ o4
in
let print_reg_pair (dst src:reg) =
print_pair (print_reg dst p) (print_reg src p)
in
let print_reg_mem (o1:reg) (o2:maddr) =
print_pair (print_reg o1 p) (print_maddr o2 p)
in
let print_reg_triple (dst src1 src2:reg) =
print_triple (print_reg dst p) (print_reg src1 p) (print_reg src2 p)
in
let print_reg_imm (dst:reg) (src:int) =
print_pair (print_reg dst p) (p.const src)
in
let print_reg_pair_imm (dst src1:reg) (src2:int) =
print_triple (print_reg dst p) (print_reg src1 p) (p.const src2)
in
let print_reg_vec (dst:reg) (src:vec) (vsr:bool) =
print_pair (print_reg dst p) (print_vec src vsr p)
in
let print_vec_reg (dst:vec) (src:reg) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_reg src p)
in
let print_vec_reg_pair (dst:vec) (src1 src2:reg) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_reg src1 p) (print_reg src2 p)
in
let print_vec_pair (dst src:vec) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_vec src vsr p)
in
let print_vec_triple (dst src1 src2:vec) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p)
in
let print_vec_quadruple (dst src1 src2 src3:vec) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (print_vec src3 vsr p)
in
let print_vec_imm (dst:vec) (src:int) (vsr:bool) =
print_pair (print_vec dst vsr p) (p.const src)
in
let print_vec_pair_imm (dst src:vec) (imm:int) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src vsr p) (p.const imm)
in
let print_vec_triple_imm (dst src1 src2:vec) (count:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (p.const count)
in
let print_vec_mem (o1:vec) (o2:maddr) (vsr:bool) =
print_pair (print_vec o1 vsr p) (print_maddr o2 p)
in
let print_vec_pair_imm_pair (dst src:vec) (s0 s1:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src vsr p) (p.const s0) (p.const s1)
in
match ins with
| Move dst src -> " mr " ^ print_reg_pair dst src
| Load64 dst base offset -> " ld " ^ print_reg_mem dst ({ address = base; offset = offset })
| Store64 src base offset -> " std " ^ print_reg_mem src ({ address = base; offset = offset })
| LoadImm64 dst src -> " li " ^ print_reg_imm dst src
| LoadImmShl64 dst src -> " lis " ^ print_reg_imm dst src
| AddLa dst src1 src2 -> " la " ^ print_reg_mem dst ({ address = src1; offset = src2 })
| Add dst src1 src2 -> " add " ^ print_reg_triple dst src1 src2
| AddImm dst src1 src2 -> " addi " ^ print_reg_pair_imm dst src1 src2
| AddCarry dst src1 src2 -> " addc " ^ print_reg_triple dst src1 src2
| AddExtended dst src1 src2 -> " adde " ^ print_reg_triple dst src1 src2
| AddExtendedOV dst src1 src2 -> " addex " ^ print_reg_triple dst src1 src2
| Sub dst src1 src2 -> " sub " ^ print_reg_triple dst src1 src2
| SubImm dst src1 src2 -> " subi " ^ print_reg_pair_imm dst src1 src2
| MulLow64 dst src1 src2 -> " mulld " ^ print_reg_triple dst src1 src2
| MulHigh64U dst src1 src2 -> " mulhdu " ^ print_reg_triple dst src1 src2
| Xor dst src1 src2 -> " xor " ^ print_reg_triple dst src1 src2
| And dst src1 src2 -> " and " ^ print_reg_triple dst src1 src2
| Sr64Imm dst src1 src2 -> " srdi " ^ print_reg_pair_imm dst src1 src2
| Sl64Imm dst src1 src2 -> " sldi " ^ print_reg_pair_imm dst src1 src2
| Sr64 dst src1 src2 -> " srd " ^ print_reg_triple dst src1 src2
| Sl64 dst src1 src2 -> " sld " ^ print_reg_triple dst src1 src2
| Vmr dst src -> " vmr " ^ print_vec_pair dst src false
| Mfvsrd dst src -> " mfvsrd " ^ print_reg_vec dst src true
| Mfvsrld dst src -> " mfvsrld " ^ print_reg_vec dst src true
| Mtvsrdd dst src1 src2 -> " mtvsrdd " ^ print_vec_reg_pair dst src1 src2 true
| Mtvsrws dst src -> " mtvsrws " ^ print_vec_reg dst src true
| Vadduwm dst src1 src2 -> " vadduwm " ^ print_vec_triple dst src1 src2 false
| Vxor dst src1 src2 -> " vxor " ^ print_vec_triple dst src1 src2 false
| Vand dst src1 src2 -> " vand " ^ print_vec_triple dst src1 src2 false
| Vslw dst src1 src2 -> " vslw " ^ print_vec_triple dst src1 src2 false
| Vsrw dst src1 src2 -> " vsrw " ^ print_vec_triple dst src1 src2 false
| Vsl dst src1 src2 -> " vsl " ^ print_vec_triple dst src1 src2 false
| Vcmpequw dst src1 src2 -> " vcmpequw " ^ print_vec_triple dst src1 src2 false
| Vsldoi dst src1 src2 count -> " vsldoi " ^ print_vec_triple_imm dst src1 src2 count false
| Vmrghw dst src1 src2 -> " vmrghw " ^ print_vec_triple dst src1 src2 false
| Xxmrghd dst src1 src2 -> " xxmrghd " ^ print_vec_triple dst src1 src2 true
| Vsel dst src1 src2 sel -> " vsel " ^ print_vec_quadruple dst src1 src2 sel false
| Vspltw dst src uim -> " vspltw " ^ print_vec_pair_imm dst src uim false
| Vspltisw dst src -> " vspltisw " ^ print_vec_imm dst src false
| Vspltisb dst src -> " vspltisb " ^ print_vec_imm dst src false
| Load128 dst base offset -> " lvx " ^ print_vec_reg_pair dst offset base false
| Store128 src base offset -> " stvx " ^ print_vec_reg_pair src offset base false
| Load128Word4 dst base -> " lxvw4x " ^ print_vec_reg_pair dst 0 base true
| Load128Word4Index dst base offset -> " lxvw4x " ^ print_vec_reg_pair dst offset base true
| Store128Word4 src base -> " stxvw4x " ^ print_vec_reg_pair src 0 base true
| Store128Word4Index src base offset -> " stxvw4x " ^ print_vec_reg_pair src offset base true
| Load128Byte16 dst base -> " lxvb16x " ^ print_vec_reg_pair dst 0 base true
| Load128Byte16Index dst base offset -> " lxvb16x " ^ print_vec_reg_pair dst offset base true
| Store128Byte16 src base -> " stxvb16x " ^ print_vec_reg_pair src 0 base true
| Store128Byte16Index src base offset -> " stxvb16x " ^ print_vec_reg_pair src offset base true
| Vshasigmaw0 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 0 false
| Vshasigmaw1 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 15 false
| Vshasigmaw2 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 0 false
| Vshasigmaw3 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 15 false
| Vsbox dst src -> " vsbox " ^ print_vec_pair dst src false
| RotWord dst src1 src2 -> " vrlw " ^ print_vec_triple dst src1 src2 false
| Vcipher dst src1 src2 -> " vcipher " ^ print_vec_triple dst src1 src2 false
| Vcipherlast dst src1 src2 -> " vcipherlast " ^ print_vec_triple dst src1 src2 false
| Vncipher dst src1 src2 -> " vncipher " ^ print_vec_triple dst src1 src2 false
| Vncipherlast dst src1 src2 -> " vncipherlast " ^ print_vec_triple dst src1 src2 false
| Vpmsumd dst src1 src2 -> " vpmsumd " ^ print_vec_triple dst src1 src2 false
| Alloc n -> " subi " ^ print_reg_pair_imm 1 1 n
| Dealloc n -> " addi " ^ print_reg_pair_imm 1 1 n
| StoreStack128 src t offset -> " stxv " ^ print_vec_mem src ({ address = 1; offset = offset }) true
| LoadStack128 dst t offset -> " lxv " ^ print_vec_mem dst ({ address = 1; offset = offset }) true
| StoreStack64 src t offset -> " std " ^ print_reg_mem src ({ address = 1; offset = offset })
| LoadStack64 dst t offset -> " ld " ^ print_reg_mem dst ({ address = 1; offset = offset })
| Ghost _ -> ""
let print_cmp (c:ocmp) (counter:int) (p:printer) : string =
let print_cmp_ops (o1:cmp_opr) (o2:cmp_opr) : string =
match o2 with
| CReg r -> " cmpld " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (print_reg r p) ^ "\n"
| CImm n -> " cmpldi " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (string_of_int n) ^ "\n"
in
match c with
| OEq o1 o2 -> print_cmp_ops o1 o2 ^ " beq " ^ "L" ^ string_of_int counter ^ "\n"
| ONe o1 o2 -> print_cmp_ops o1 o2 ^ " bne "^ "L" ^ string_of_int counter ^ "\n"
| OLe o1 o2 -> print_cmp_ops o1 o2 ^ " ble "^ "L" ^ string_of_int counter ^ "\n"
| OGe o1 o2 -> print_cmp_ops o1 o2 ^ " bge "^ "L" ^ string_of_int counter ^ "\n"
| OLt o1 o2 -> print_cmp_ops o1 o2 ^ " blt " ^ "L" ^ string_of_int counter ^ "\n"
| OGt o1 o2 -> print_cmp_ops o1 o2 ^ " bgt " ^ "L" ^ string_of_int counter ^ "\n"
let rec print_block (b:codes) (n:int) (p:printer) : string & int =
match b with
| Nil -> ("", n)
| head :: tail ->
let (head_str, n') = print_code head n p in
let (rest, n'') = print_block tail n' p in
(head_str ^ rest, n'')
and print_code (c:code) (n:int) (p:printer) : string & int =
match c with
| Ins ins -> (print_ins ins p ^ "\n", n)
| Block b -> print_block b n p
| IfElse cond true_code false_code ->
let n1 = n in
let n2 = n + 1 in
let cmp = print_cmp (cmp_not cond) n1 p in
let (true_str, n') = print_code true_code (n + 2) p in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = "L" ^ string_of_int n1 ^ ":\n" in
let (false_str, n') = print_code false_code n' p in
let label2 = "L" ^ string_of_int n2 ^ ":\n" in
(cmp ^ true_str ^ branch ^ label1 ^ false_str ^ label2, n')
| While cond body ->
let n1 = n in
let n2 = n + 1 in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = p.align() ^ " 4\nL" ^ string_of_int n1 ^ ":\n" in
let (body_str, n') = print_code body (n + 2) p in
let label2 = p.align() ^ " 4\nL" ^ string_of_int n2 ^ ":\n" in
let cmp = print_cmp cond n1 p in
(branch ^ label1 ^ body_str ^ label2 ^ cmp, n')
let print_header (p:printer) =
print_string (p.header()) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
name: Prims.string ->
code: Vale.PPC64LE.Semantics_s.code ->
label: Prims.int ->
p: Vale.PPC64LE.Print_s.printer
-> FStar.All.ML Prims.int | FStar.All.ML | [
"ml"
] | [] | [
"Prims.string",
"Vale.PPC64LE.Semantics_s.code",
"Prims.int",
"Vale.PPC64LE.Print_s.printer",
"Prims.unit",
"FStar.IO.print_string",
"Prims.op_Hat",
"Vale.PPC64LE.Print_s.__proj__Mkprinter__item__ret",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Print_s.print_code",
"Vale.PPC64LE.Print_s.__proj__Mkprinter__item__proc_name"
] | [] | false | true | false | false | false | let print_proc (name: string) (code: code) (label: int) (p: printer) : FStar.All.ML int =
| let proc = p.proc_name name in
let code_str, final_label = print_code code label p in
let ret = p.ret name in
print_string (proc ^ code_str ^ ret);
final_label | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2._sigma1 | val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a) | val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a) | let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 82,
"end_line": 143,
"start_col": 0,
"start_line": 143
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> x: Spec.Hash.Definitions.word a -> Spec.Hash.Definitions.word a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.word",
"Hacl.Spec.SHA2.op_Hat_Dot",
"Hacl.Spec.SHA2.op_Greater_Greater_Greater_Dot",
"Hacl.Spec.SHA2.__proj__Mkops__item__e3",
"Hacl.Spec.SHA2.op0",
"Hacl.Spec.SHA2.__proj__Mkops__item__e4",
"Hacl.Spec.SHA2.op_Greater_Greater_Dot",
"Hacl.Spec.SHA2.__proj__Mkops__item__e5"
] | [] | false | false | false | false | false | let _sigma1 a x =
| (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5) | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_footer | val print_footer : p: Vale.PPC64LE.Print_s.printer -> FStar.All.ML Prims.unit | let print_footer (p:printer) =
print_string (p.footer()) | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 232,
"start_col": 0,
"start_line": 231
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v
let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p)
let cmp_not(o:ocmp) : ocmp =
match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2
// Sanity check
let _ = assert (forall o . o == cmp_not (cmp_not o))
let print_first_cmp_opr (o:cmp_opr) (p:printer) =
match o with
| CReg r -> print_reg r p
| _ -> "!!! INVALID first compare operand !!! Expected general purpose register."
let print_ins (ins:ins) (p:printer) =
let print_pair (o1 o2:string) =
o1 ^ ", " ^ o2
in
let print_triple (o1 o2 o3:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3
in
let print_quadruple (o1 o2 o3 o4:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3 ^ ", " ^ o4
in
let print_reg_pair (dst src:reg) =
print_pair (print_reg dst p) (print_reg src p)
in
let print_reg_mem (o1:reg) (o2:maddr) =
print_pair (print_reg o1 p) (print_maddr o2 p)
in
let print_reg_triple (dst src1 src2:reg) =
print_triple (print_reg dst p) (print_reg src1 p) (print_reg src2 p)
in
let print_reg_imm (dst:reg) (src:int) =
print_pair (print_reg dst p) (p.const src)
in
let print_reg_pair_imm (dst src1:reg) (src2:int) =
print_triple (print_reg dst p) (print_reg src1 p) (p.const src2)
in
let print_reg_vec (dst:reg) (src:vec) (vsr:bool) =
print_pair (print_reg dst p) (print_vec src vsr p)
in
let print_vec_reg (dst:vec) (src:reg) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_reg src p)
in
let print_vec_reg_pair (dst:vec) (src1 src2:reg) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_reg src1 p) (print_reg src2 p)
in
let print_vec_pair (dst src:vec) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_vec src vsr p)
in
let print_vec_triple (dst src1 src2:vec) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p)
in
let print_vec_quadruple (dst src1 src2 src3:vec) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (print_vec src3 vsr p)
in
let print_vec_imm (dst:vec) (src:int) (vsr:bool) =
print_pair (print_vec dst vsr p) (p.const src)
in
let print_vec_pair_imm (dst src:vec) (imm:int) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src vsr p) (p.const imm)
in
let print_vec_triple_imm (dst src1 src2:vec) (count:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (p.const count)
in
let print_vec_mem (o1:vec) (o2:maddr) (vsr:bool) =
print_pair (print_vec o1 vsr p) (print_maddr o2 p)
in
let print_vec_pair_imm_pair (dst src:vec) (s0 s1:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src vsr p) (p.const s0) (p.const s1)
in
match ins with
| Move dst src -> " mr " ^ print_reg_pair dst src
| Load64 dst base offset -> " ld " ^ print_reg_mem dst ({ address = base; offset = offset })
| Store64 src base offset -> " std " ^ print_reg_mem src ({ address = base; offset = offset })
| LoadImm64 dst src -> " li " ^ print_reg_imm dst src
| LoadImmShl64 dst src -> " lis " ^ print_reg_imm dst src
| AddLa dst src1 src2 -> " la " ^ print_reg_mem dst ({ address = src1; offset = src2 })
| Add dst src1 src2 -> " add " ^ print_reg_triple dst src1 src2
| AddImm dst src1 src2 -> " addi " ^ print_reg_pair_imm dst src1 src2
| AddCarry dst src1 src2 -> " addc " ^ print_reg_triple dst src1 src2
| AddExtended dst src1 src2 -> " adde " ^ print_reg_triple dst src1 src2
| AddExtendedOV dst src1 src2 -> " addex " ^ print_reg_triple dst src1 src2
| Sub dst src1 src2 -> " sub " ^ print_reg_triple dst src1 src2
| SubImm dst src1 src2 -> " subi " ^ print_reg_pair_imm dst src1 src2
| MulLow64 dst src1 src2 -> " mulld " ^ print_reg_triple dst src1 src2
| MulHigh64U dst src1 src2 -> " mulhdu " ^ print_reg_triple dst src1 src2
| Xor dst src1 src2 -> " xor " ^ print_reg_triple dst src1 src2
| And dst src1 src2 -> " and " ^ print_reg_triple dst src1 src2
| Sr64Imm dst src1 src2 -> " srdi " ^ print_reg_pair_imm dst src1 src2
| Sl64Imm dst src1 src2 -> " sldi " ^ print_reg_pair_imm dst src1 src2
| Sr64 dst src1 src2 -> " srd " ^ print_reg_triple dst src1 src2
| Sl64 dst src1 src2 -> " sld " ^ print_reg_triple dst src1 src2
| Vmr dst src -> " vmr " ^ print_vec_pair dst src false
| Mfvsrd dst src -> " mfvsrd " ^ print_reg_vec dst src true
| Mfvsrld dst src -> " mfvsrld " ^ print_reg_vec dst src true
| Mtvsrdd dst src1 src2 -> " mtvsrdd " ^ print_vec_reg_pair dst src1 src2 true
| Mtvsrws dst src -> " mtvsrws " ^ print_vec_reg dst src true
| Vadduwm dst src1 src2 -> " vadduwm " ^ print_vec_triple dst src1 src2 false
| Vxor dst src1 src2 -> " vxor " ^ print_vec_triple dst src1 src2 false
| Vand dst src1 src2 -> " vand " ^ print_vec_triple dst src1 src2 false
| Vslw dst src1 src2 -> " vslw " ^ print_vec_triple dst src1 src2 false
| Vsrw dst src1 src2 -> " vsrw " ^ print_vec_triple dst src1 src2 false
| Vsl dst src1 src2 -> " vsl " ^ print_vec_triple dst src1 src2 false
| Vcmpequw dst src1 src2 -> " vcmpequw " ^ print_vec_triple dst src1 src2 false
| Vsldoi dst src1 src2 count -> " vsldoi " ^ print_vec_triple_imm dst src1 src2 count false
| Vmrghw dst src1 src2 -> " vmrghw " ^ print_vec_triple dst src1 src2 false
| Xxmrghd dst src1 src2 -> " xxmrghd " ^ print_vec_triple dst src1 src2 true
| Vsel dst src1 src2 sel -> " vsel " ^ print_vec_quadruple dst src1 src2 sel false
| Vspltw dst src uim -> " vspltw " ^ print_vec_pair_imm dst src uim false
| Vspltisw dst src -> " vspltisw " ^ print_vec_imm dst src false
| Vspltisb dst src -> " vspltisb " ^ print_vec_imm dst src false
| Load128 dst base offset -> " lvx " ^ print_vec_reg_pair dst offset base false
| Store128 src base offset -> " stvx " ^ print_vec_reg_pair src offset base false
| Load128Word4 dst base -> " lxvw4x " ^ print_vec_reg_pair dst 0 base true
| Load128Word4Index dst base offset -> " lxvw4x " ^ print_vec_reg_pair dst offset base true
| Store128Word4 src base -> " stxvw4x " ^ print_vec_reg_pair src 0 base true
| Store128Word4Index src base offset -> " stxvw4x " ^ print_vec_reg_pair src offset base true
| Load128Byte16 dst base -> " lxvb16x " ^ print_vec_reg_pair dst 0 base true
| Load128Byte16Index dst base offset -> " lxvb16x " ^ print_vec_reg_pair dst offset base true
| Store128Byte16 src base -> " stxvb16x " ^ print_vec_reg_pair src 0 base true
| Store128Byte16Index src base offset -> " stxvb16x " ^ print_vec_reg_pair src offset base true
| Vshasigmaw0 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 0 false
| Vshasigmaw1 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 15 false
| Vshasigmaw2 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 0 false
| Vshasigmaw3 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 15 false
| Vsbox dst src -> " vsbox " ^ print_vec_pair dst src false
| RotWord dst src1 src2 -> " vrlw " ^ print_vec_triple dst src1 src2 false
| Vcipher dst src1 src2 -> " vcipher " ^ print_vec_triple dst src1 src2 false
| Vcipherlast dst src1 src2 -> " vcipherlast " ^ print_vec_triple dst src1 src2 false
| Vncipher dst src1 src2 -> " vncipher " ^ print_vec_triple dst src1 src2 false
| Vncipherlast dst src1 src2 -> " vncipherlast " ^ print_vec_triple dst src1 src2 false
| Vpmsumd dst src1 src2 -> " vpmsumd " ^ print_vec_triple dst src1 src2 false
| Alloc n -> " subi " ^ print_reg_pair_imm 1 1 n
| Dealloc n -> " addi " ^ print_reg_pair_imm 1 1 n
| StoreStack128 src t offset -> " stxv " ^ print_vec_mem src ({ address = 1; offset = offset }) true
| LoadStack128 dst t offset -> " lxv " ^ print_vec_mem dst ({ address = 1; offset = offset }) true
| StoreStack64 src t offset -> " std " ^ print_reg_mem src ({ address = 1; offset = offset })
| LoadStack64 dst t offset -> " ld " ^ print_reg_mem dst ({ address = 1; offset = offset })
| Ghost _ -> ""
let print_cmp (c:ocmp) (counter:int) (p:printer) : string =
let print_cmp_ops (o1:cmp_opr) (o2:cmp_opr) : string =
match o2 with
| CReg r -> " cmpld " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (print_reg r p) ^ "\n"
| CImm n -> " cmpldi " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (string_of_int n) ^ "\n"
in
match c with
| OEq o1 o2 -> print_cmp_ops o1 o2 ^ " beq " ^ "L" ^ string_of_int counter ^ "\n"
| ONe o1 o2 -> print_cmp_ops o1 o2 ^ " bne "^ "L" ^ string_of_int counter ^ "\n"
| OLe o1 o2 -> print_cmp_ops o1 o2 ^ " ble "^ "L" ^ string_of_int counter ^ "\n"
| OGe o1 o2 -> print_cmp_ops o1 o2 ^ " bge "^ "L" ^ string_of_int counter ^ "\n"
| OLt o1 o2 -> print_cmp_ops o1 o2 ^ " blt " ^ "L" ^ string_of_int counter ^ "\n"
| OGt o1 o2 -> print_cmp_ops o1 o2 ^ " bgt " ^ "L" ^ string_of_int counter ^ "\n"
let rec print_block (b:codes) (n:int) (p:printer) : string & int =
match b with
| Nil -> ("", n)
| head :: tail ->
let (head_str, n') = print_code head n p in
let (rest, n'') = print_block tail n' p in
(head_str ^ rest, n'')
and print_code (c:code) (n:int) (p:printer) : string & int =
match c with
| Ins ins -> (print_ins ins p ^ "\n", n)
| Block b -> print_block b n p
| IfElse cond true_code false_code ->
let n1 = n in
let n2 = n + 1 in
let cmp = print_cmp (cmp_not cond) n1 p in
let (true_str, n') = print_code true_code (n + 2) p in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = "L" ^ string_of_int n1 ^ ":\n" in
let (false_str, n') = print_code false_code n' p in
let label2 = "L" ^ string_of_int n2 ^ ":\n" in
(cmp ^ true_str ^ branch ^ label1 ^ false_str ^ label2, n')
| While cond body ->
let n1 = n in
let n2 = n + 1 in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = p.align() ^ " 4\nL" ^ string_of_int n1 ^ ":\n" in
let (body_str, n') = print_code body (n + 2) p in
let label2 = p.align() ^ " 4\nL" ^ string_of_int n2 ^ ":\n" in
let cmp = print_cmp cond n1 p in
(branch ^ label1 ^ body_str ^ label2 ^ cmp, n')
let print_header (p:printer) =
print_string (p.header())
let print_proc (name:string) (code:code) (label:int) (p:printer) : FStar.All.ML int =
let proc = p.proc_name name in
let (code_str, final_label) = print_code code label p in
let ret = p.ret name in
print_string (proc ^ code_str ^ ret);
final_label | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Vale.PPC64LE.Print_s.printer -> FStar.All.ML Prims.unit | FStar.All.ML | [
"ml"
] | [] | [
"Vale.PPC64LE.Print_s.printer",
"FStar.IO.print_string",
"Vale.PPC64LE.Print_s.__proj__Mkprinter__item__footer",
"Prims.unit"
] | [] | false | true | false | false | false | let print_footer (p: printer) =
| print_string (p.footer ()) | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.sha224 | val sha224 : len: Hacl.Spec.SHA2.len_lt_max_a_t Spec.Hash.Definitions.SHA2_224 ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len}
-> Lib.Sequence.lseq Lib.IntTypes.uint8
(Spec.Hash.Definitions.hash_length Spec.Hash.Definitions.SHA2_224) | let sha224 (len:len_lt_max_a_t SHA2_224) (b:seq uint8{length b = len}) =
hash #SHA2_224 len b | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 301,
"start_col": 0,
"start_line": 300
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1)
let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash
let store_state (a:sha2_alg) (hashw:words_state a) : Tot (lseq uint8 (8 * word_length a)) =
Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw
let emit (a:sha2_alg) (h:lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) =
sub h 0 (hash_length a)
let finish (a:sha2_alg) (st:words_state a) : Tot (lseq uint8 (hash_length a)) =
let hseq = store_state a st in
emit a hseq
let update_block (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len})
(i:nat{i < len / block_length a}) (st:words_state a) : words_state a
=
let mb = Seq.slice b (i * block_length a) (i * block_length a + block_length a) in
update a mb st
let update_nblocks (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) (st:words_state a) : words_state a =
let blocks = len / block_length a in
Lib.LoopCombinators.repeati blocks (update_block a len b) st
let hash (#a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) =
let len' : len_t a = mk_len_t a len in
let st = init a in
let st = update_nblocks a len b st in
let rem = len % block_length a in
let mb = Seq.slice b (len - rem) len in
let st = update_last a len' rem mb st in
finish a st | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
len: Hacl.Spec.SHA2.len_lt_max_a_t Spec.Hash.Definitions.SHA2_224 ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len}
-> Lib.Sequence.lseq Lib.IntTypes.uint8
(Spec.Hash.Definitions.hash_length Spec.Hash.Definitions.SHA2_224) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.SHA2.len_lt_max_a_t",
"Spec.Hash.Definitions.SHA2_224",
"Lib.Sequence.seq",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"Lib.Sequence.length",
"Hacl.Spec.SHA2.hash",
"Lib.Sequence.lseq",
"Spec.Hash.Definitions.hash_length"
] | [] | false | false | false | false | false | let sha224 (len: len_lt_max_a_t SHA2_224) (b: seq uint8 {length b = len}) =
| hash #SHA2_224 len b | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.sha512 | val sha512 : len: Hacl.Spec.SHA2.len_lt_max_a_t Spec.Hash.Definitions.SHA2_512 ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len}
-> Lib.Sequence.lseq Lib.IntTypes.uint8
(Spec.Hash.Definitions.hash_length Spec.Hash.Definitions.SHA2_512) | let sha512 (len:len_lt_max_a_t SHA2_512) (b:seq uint8{length b = len}) =
hash #SHA2_512 len b | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 310,
"start_col": 0,
"start_line": 309
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1)
let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash
let store_state (a:sha2_alg) (hashw:words_state a) : Tot (lseq uint8 (8 * word_length a)) =
Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw
let emit (a:sha2_alg) (h:lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) =
sub h 0 (hash_length a)
let finish (a:sha2_alg) (st:words_state a) : Tot (lseq uint8 (hash_length a)) =
let hseq = store_state a st in
emit a hseq
let update_block (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len})
(i:nat{i < len / block_length a}) (st:words_state a) : words_state a
=
let mb = Seq.slice b (i * block_length a) (i * block_length a + block_length a) in
update a mb st
let update_nblocks (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) (st:words_state a) : words_state a =
let blocks = len / block_length a in
Lib.LoopCombinators.repeati blocks (update_block a len b) st
let hash (#a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) =
let len' : len_t a = mk_len_t a len in
let st = init a in
let st = update_nblocks a len b st in
let rem = len % block_length a in
let mb = Seq.slice b (len - rem) len in
let st = update_last a len' rem mb st in
finish a st
let sha224 (len:len_lt_max_a_t SHA2_224) (b:seq uint8{length b = len}) =
hash #SHA2_224 len b
let sha256 (len:len_lt_max_a_t SHA2_256) (b:seq uint8{length b = len}) =
hash #SHA2_256 len b
let sha384 (len:len_lt_max_a_t SHA2_384) (b:seq uint8{length b = len}) =
hash #SHA2_384 len b | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
len: Hacl.Spec.SHA2.len_lt_max_a_t Spec.Hash.Definitions.SHA2_512 ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len}
-> Lib.Sequence.lseq Lib.IntTypes.uint8
(Spec.Hash.Definitions.hash_length Spec.Hash.Definitions.SHA2_512) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.SHA2.len_lt_max_a_t",
"Spec.Hash.Definitions.SHA2_512",
"Lib.Sequence.seq",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"Lib.Sequence.length",
"Hacl.Spec.SHA2.hash",
"Lib.Sequence.lseq",
"Spec.Hash.Definitions.hash_length"
] | [] | false | false | false | false | false | let sha512 (len: len_lt_max_a_t SHA2_512) (b: seq uint8 {length b = len}) =
| hash #SHA2_512 len b | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.padded_blocks | val padded_blocks (a: sha2_alg) (len: nat{len <= block_length a}) : n: nat{n <= 2} | val padded_blocks (a: sha2_alg) (len: nat{len <= block_length a}) : n: nat{n <= 2} | let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2 | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 61,
"end_line": 237,
"start_col": 0,
"start_line": 236
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> len: Prims.nat{len <= Spec.Hash.Definitions.block_length a}
-> n: Prims.nat{n <= 2} | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.Hash.Definitions.block_length",
"Prims.op_Addition",
"Spec.Hash.Definitions.len_length",
"Prims.bool"
] | [] | false | false | false | false | false | let padded_blocks (a: sha2_alg) (len: nat{len <= block_length a}) : n: nat{n <= 2} =
| if (len + len_length a + 1 <= block_length a) then 1 else 2 | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.update_block | val update_block
(a: sha2_alg)
(len: len_lt_max_a_t a)
(b: seq uint8 {length b = len})
(i: nat{i < len / block_length a})
(st: words_state a)
: words_state a | val update_block
(a: sha2_alg)
(len: len_lt_max_a_t a)
(b: seq uint8 {length b = len})
(i: nat{i < len / block_length a})
(st: words_state a)
: words_state a | let update_block (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len})
(i:nat{i < len / block_length a}) (st:words_state a) : words_state a
=
let mb = Seq.slice b (i * block_length a) (i * block_length a + block_length a) in
update a mb st | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 283,
"start_col": 0,
"start_line": 279
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1)
let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash
let store_state (a:sha2_alg) (hashw:words_state a) : Tot (lseq uint8 (8 * word_length a)) =
Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw
let emit (a:sha2_alg) (h:lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) =
sub h 0 (hash_length a)
let finish (a:sha2_alg) (st:words_state a) : Tot (lseq uint8 (hash_length a)) =
let hseq = store_state a st in
emit a hseq | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
len: Hacl.Spec.SHA2.len_lt_max_a_t a ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len} ->
i: Prims.nat{i < len / Spec.Hash.Definitions.block_length a} ->
st: Spec.Hash.Definitions.words_state a
-> Spec.Hash.Definitions.words_state a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.len_lt_max_a_t",
"Lib.Sequence.seq",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"Lib.Sequence.length",
"Prims.op_LessThan",
"Prims.op_Division",
"Spec.Hash.Definitions.block_length",
"Spec.Hash.Definitions.words_state",
"Hacl.Spec.SHA2.update",
"FStar.Seq.Base.seq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.Seq.Base.slice",
"FStar.Mul.op_Star",
"Prims.op_Addition"
] | [] | false | false | false | false | false | let update_block
(a: sha2_alg)
(len: len_lt_max_a_t a)
(b: seq uint8 {length b = len})
(i: nat{i < len / block_length a})
(st: words_state a)
: words_state a =
| let mb = Seq.slice b (i * block_length a) (i * block_length a + block_length a) in
update a mb st | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.sha384 | val sha384 : len: Hacl.Spec.SHA2.len_lt_max_a_t Spec.Hash.Definitions.SHA2_384 ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len}
-> Lib.Sequence.lseq Lib.IntTypes.uint8
(Spec.Hash.Definitions.hash_length Spec.Hash.Definitions.SHA2_384) | let sha384 (len:len_lt_max_a_t SHA2_384) (b:seq uint8{length b = len}) =
hash #SHA2_384 len b | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 307,
"start_col": 0,
"start_line": 306
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1)
let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash
let store_state (a:sha2_alg) (hashw:words_state a) : Tot (lseq uint8 (8 * word_length a)) =
Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw
let emit (a:sha2_alg) (h:lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) =
sub h 0 (hash_length a)
let finish (a:sha2_alg) (st:words_state a) : Tot (lseq uint8 (hash_length a)) =
let hseq = store_state a st in
emit a hseq
let update_block (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len})
(i:nat{i < len / block_length a}) (st:words_state a) : words_state a
=
let mb = Seq.slice b (i * block_length a) (i * block_length a + block_length a) in
update a mb st
let update_nblocks (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) (st:words_state a) : words_state a =
let blocks = len / block_length a in
Lib.LoopCombinators.repeati blocks (update_block a len b) st
let hash (#a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) =
let len' : len_t a = mk_len_t a len in
let st = init a in
let st = update_nblocks a len b st in
let rem = len % block_length a in
let mb = Seq.slice b (len - rem) len in
let st = update_last a len' rem mb st in
finish a st
let sha224 (len:len_lt_max_a_t SHA2_224) (b:seq uint8{length b = len}) =
hash #SHA2_224 len b
let sha256 (len:len_lt_max_a_t SHA2_256) (b:seq uint8{length b = len}) =
hash #SHA2_256 len b | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
len: Hacl.Spec.SHA2.len_lt_max_a_t Spec.Hash.Definitions.SHA2_384 ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len}
-> Lib.Sequence.lseq Lib.IntTypes.uint8
(Spec.Hash.Definitions.hash_length Spec.Hash.Definitions.SHA2_384) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.SHA2.len_lt_max_a_t",
"Spec.Hash.Definitions.SHA2_384",
"Lib.Sequence.seq",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"Lib.Sequence.length",
"Hacl.Spec.SHA2.hash",
"Lib.Sequence.lseq",
"Spec.Hash.Definitions.hash_length"
] | [] | false | false | false | false | false | let sha384 (len: len_lt_max_a_t SHA2_384) (b: seq uint8 {length b = len}) =
| hash #SHA2_384 len b | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.sha256 | val sha256 : len: Hacl.Spec.SHA2.len_lt_max_a_t Spec.Hash.Definitions.SHA2_256 ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len}
-> Lib.Sequence.lseq Lib.IntTypes.uint8
(Spec.Hash.Definitions.hash_length Spec.Hash.Definitions.SHA2_256) | let sha256 (len:len_lt_max_a_t SHA2_256) (b:seq uint8{length b = len}) =
hash #SHA2_256 len b | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 304,
"start_col": 0,
"start_line": 303
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1)
let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash
let store_state (a:sha2_alg) (hashw:words_state a) : Tot (lseq uint8 (8 * word_length a)) =
Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw
let emit (a:sha2_alg) (h:lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) =
sub h 0 (hash_length a)
let finish (a:sha2_alg) (st:words_state a) : Tot (lseq uint8 (hash_length a)) =
let hseq = store_state a st in
emit a hseq
let update_block (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len})
(i:nat{i < len / block_length a}) (st:words_state a) : words_state a
=
let mb = Seq.slice b (i * block_length a) (i * block_length a + block_length a) in
update a mb st
let update_nblocks (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) (st:words_state a) : words_state a =
let blocks = len / block_length a in
Lib.LoopCombinators.repeati blocks (update_block a len b) st
let hash (#a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) =
let len' : len_t a = mk_len_t a len in
let st = init a in
let st = update_nblocks a len b st in
let rem = len % block_length a in
let mb = Seq.slice b (len - rem) len in
let st = update_last a len' rem mb st in
finish a st
let sha224 (len:len_lt_max_a_t SHA2_224) (b:seq uint8{length b = len}) =
hash #SHA2_224 len b | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
len: Hacl.Spec.SHA2.len_lt_max_a_t Spec.Hash.Definitions.SHA2_256 ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len}
-> Lib.Sequence.lseq Lib.IntTypes.uint8
(Spec.Hash.Definitions.hash_length Spec.Hash.Definitions.SHA2_256) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Spec.SHA2.len_lt_max_a_t",
"Spec.Hash.Definitions.SHA2_256",
"Lib.Sequence.seq",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"Lib.Sequence.length",
"Hacl.Spec.SHA2.hash",
"Lib.Sequence.lseq",
"Spec.Hash.Definitions.hash_length"
] | [] | false | false | false | false | false | let sha256 (len: len_lt_max_a_t SHA2_256) (b: seq uint8 {length b = len}) =
| hash #SHA2_256 len b | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.update_last | val update_last
(a: sha2_alg)
(totlen: len_t a)
(len: nat{len <= block_length a})
(b: bytes{S.length b = len})
(hash: words_state a)
: Tot (words_state a) | val update_last
(a: sha2_alg)
(totlen: len_t a)
(len: nat{len <= block_length a})
(b: bytes{S.length b = len})
(hash: words_state a)
: Tot (words_state a) | let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 263,
"start_col": 0,
"start_line": 254
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1) | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
totlen: Spec.Hash.Definitions.len_t a ->
len: Prims.nat{len <= Spec.Hash.Definitions.block_length a} ->
b: Spec.Hash.Definitions.bytes{FStar.Seq.Base.length b = len} ->
hash: Spec.Hash.Definitions.words_state a
-> Spec.Hash.Definitions.words_state a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.len_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.Hash.Definitions.block_length",
"Spec.Hash.Definitions.bytes",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.words_state",
"Hacl.Spec.SHA2.block_t",
"Prims.op_GreaterThan",
"Hacl.Spec.SHA2.update",
"Prims.bool",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.SHA2.load_last",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.numbytes",
"Spec.Hash.Definitions.len_int_type",
"Lib.ByteSequence.uint_to_bytes_be",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Lib.IntTypes.shift_left",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.IntTypes.secret",
"FStar.UInt32.__uint_to_t",
"FStar.Mul.op_Star",
"Hacl.Spec.SHA2.padded_blocks"
] | [] | false | false | false | false | false | let update_last
(a: sha2_alg)
(totlen: len_t a)
(len: nat{len <= block_length a})
(b: bytes{S.length b = len})
(hash: words_state a)
: Tot (words_state a) =
| let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let b0, b1 = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.finish | val finish (a: sha2_alg) (st: words_state a) : Tot (lseq uint8 (hash_length a)) | val finish (a: sha2_alg) (st: words_state a) : Tot (lseq uint8 (hash_length a)) | let finish (a:sha2_alg) (st:words_state a) : Tot (lseq uint8 (hash_length a)) =
let hseq = store_state a st in
emit a hseq | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 276,
"start_col": 0,
"start_line": 274
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1)
let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash
let store_state (a:sha2_alg) (hashw:words_state a) : Tot (lseq uint8 (8 * word_length a)) =
Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw
let emit (a:sha2_alg) (h:lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) =
sub h 0 (hash_length a) | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> st: Spec.Hash.Definitions.words_state a
-> Lib.Sequence.lseq Lib.IntTypes.uint8 (Spec.Hash.Definitions.hash_length a) | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.words_state",
"Hacl.Spec.SHA2.emit",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Spec.Hash.Definitions.word_length",
"Hacl.Spec.SHA2.store_state",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.hash_length"
] | [] | false | false | false | false | false | let finish (a: sha2_alg) (st: words_state a) : Tot (lseq uint8 (hash_length a)) =
| let hseq = store_state a st in
emit a hseq | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.update_nblocks | val update_nblocks
(a: sha2_alg)
(len: len_lt_max_a_t a)
(b: seq uint8 {length b = len})
(st: words_state a)
: words_state a | val update_nblocks
(a: sha2_alg)
(len: len_lt_max_a_t a)
(b: seq uint8 {length b = len})
(st: words_state a)
: words_state a | let update_nblocks (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) (st:words_state a) : words_state a =
let blocks = len / block_length a in
Lib.LoopCombinators.repeati blocks (update_block a len b) st | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 288,
"start_col": 0,
"start_line": 286
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1)
let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash
let store_state (a:sha2_alg) (hashw:words_state a) : Tot (lseq uint8 (8 * word_length a)) =
Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw
let emit (a:sha2_alg) (h:lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) =
sub h 0 (hash_length a)
let finish (a:sha2_alg) (st:words_state a) : Tot (lseq uint8 (hash_length a)) =
let hseq = store_state a st in
emit a hseq
let update_block (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len})
(i:nat{i < len / block_length a}) (st:words_state a) : words_state a
=
let mb = Seq.slice b (i * block_length a) (i * block_length a + block_length a) in
update a mb st | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
len: Hacl.Spec.SHA2.len_lt_max_a_t a ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len} ->
st: Spec.Hash.Definitions.words_state a
-> Spec.Hash.Definitions.words_state a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.len_lt_max_a_t",
"Lib.Sequence.seq",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"Lib.Sequence.length",
"Spec.Hash.Definitions.words_state",
"Lib.LoopCombinators.repeati",
"Hacl.Spec.SHA2.update_block",
"Prims.int",
"Prims.op_Division",
"Spec.Hash.Definitions.block_length"
] | [] | false | false | false | false | false | let update_nblocks
(a: sha2_alg)
(len: len_lt_max_a_t a)
(b: seq uint8 {length b = len})
(st: words_state a)
: words_state a =
| let blocks = len / block_length a in
Lib.LoopCombinators.repeati blocks (update_block a len b) st | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.hash | val hash : len: Hacl.Spec.SHA2.len_lt_max_a_t a ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len}
-> Lib.Sequence.lseq Lib.IntTypes.uint8 (Spec.Hash.Definitions.hash_length a) | let hash (#a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) =
let len' : len_t a = mk_len_t a len in
let st = init a in
let st = update_nblocks a len b st in
let rem = len % block_length a in
let mb = Seq.slice b (len - rem) len in
let st = update_last a len' rem mb st in
finish a st | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 13,
"end_line": 298,
"start_col": 0,
"start_line": 291
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1)
let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash
let store_state (a:sha2_alg) (hashw:words_state a) : Tot (lseq uint8 (8 * word_length a)) =
Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw
let emit (a:sha2_alg) (h:lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) =
sub h 0 (hash_length a)
let finish (a:sha2_alg) (st:words_state a) : Tot (lseq uint8 (hash_length a)) =
let hseq = store_state a st in
emit a hseq
let update_block (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len})
(i:nat{i < len / block_length a}) (st:words_state a) : words_state a
=
let mb = Seq.slice b (i * block_length a) (i * block_length a + block_length a) in
update a mb st
let update_nblocks (a:sha2_alg) (len:len_lt_max_a_t a) (b:seq uint8{length b = len}) (st:words_state a) : words_state a =
let blocks = len / block_length a in
Lib.LoopCombinators.repeati blocks (update_block a len b) st | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
len: Hacl.Spec.SHA2.len_lt_max_a_t a ->
b: Lib.Sequence.seq Lib.IntTypes.uint8 {Lib.Sequence.length b = len}
-> Lib.Sequence.lseq Lib.IntTypes.uint8 (Spec.Hash.Definitions.hash_length a) | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Hacl.Spec.SHA2.len_lt_max_a_t",
"Lib.Sequence.seq",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"Lib.Sequence.length",
"Hacl.Spec.SHA2.finish",
"Spec.Hash.Definitions.words_state",
"Hacl.Spec.SHA2.update_last",
"FStar.Seq.Base.seq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"FStar.Seq.Base.slice",
"Prims.op_Subtraction",
"Prims.int",
"Prims.op_Modulus",
"Spec.Hash.Definitions.block_length",
"Hacl.Spec.SHA2.update_nblocks",
"Hacl.Spec.SHA2.init",
"Spec.Hash.Definitions.len_t",
"Hacl.Spec.SHA2.mk_len_t",
"Lib.Sequence.lseq",
"Spec.Hash.Definitions.hash_length"
] | [] | false | false | false | false | false | let hash (#a: sha2_alg) (len: len_lt_max_a_t a) (b: seq uint8 {length b = len}) =
| let len':len_t a = mk_len_t a len in
let st = init a in
let st = update_nblocks a len b st in
let rem = len % block_length a in
let mb = Seq.slice b (len - rem) len in
let st = update_last a len' rem mb st in
finish a st | false |
|
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.emit | val emit (a: sha2_alg) (h: lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) | val emit (a: sha2_alg) (h: lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) | let emit (a:sha2_alg) (h:lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) =
sub h 0 (hash_length a) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 271,
"start_col": 0,
"start_line": 270
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1)
let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash
let store_state (a:sha2_alg) (hashw:words_state a) : Tot (lseq uint8 (8 * word_length a)) =
Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
h: Lib.Sequence.lseq Lib.IntTypes.uint8 (8 * Spec.Hash.Definitions.word_length a)
-> Lib.Sequence.lseq Lib.IntTypes.uint8 (Spec.Hash.Definitions.hash_length a) | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"FStar.Mul.op_Star",
"Spec.Hash.Definitions.word_length",
"Lib.Sequence.sub",
"Spec.Hash.Definitions.hash_length"
] | [] | false | false | false | false | false | let emit (a: sha2_alg) (h: lseq uint8 (8 * word_length a)) : Tot (lseq uint8 (hash_length a)) =
| sub h 0 (hash_length a) | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_cmp | val print_cmp (c: ocmp) (counter: int) (p: printer) : string | val print_cmp (c: ocmp) (counter: int) (p: printer) : string | let print_cmp (c:ocmp) (counter:int) (p:printer) : string =
let print_cmp_ops (o1:cmp_opr) (o2:cmp_opr) : string =
match o2 with
| CReg r -> " cmpld " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (print_reg r p) ^ "\n"
| CImm n -> " cmpldi " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (string_of_int n) ^ "\n"
in
match c with
| OEq o1 o2 -> print_cmp_ops o1 o2 ^ " beq " ^ "L" ^ string_of_int counter ^ "\n"
| ONe o1 o2 -> print_cmp_ops o1 o2 ^ " bne "^ "L" ^ string_of_int counter ^ "\n"
| OLe o1 o2 -> print_cmp_ops o1 o2 ^ " ble "^ "L" ^ string_of_int counter ^ "\n"
| OGe o1 o2 -> print_cmp_ops o1 o2 ^ " bge "^ "L" ^ string_of_int counter ^ "\n"
| OLt o1 o2 -> print_cmp_ops o1 o2 ^ " blt " ^ "L" ^ string_of_int counter ^ "\n"
| OGt o1 o2 -> print_cmp_ops o1 o2 ^ " bgt " ^ "L" ^ string_of_int counter ^ "\n" | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 84,
"end_line": 188,
"start_col": 0,
"start_line": 176
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v
let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p)
let cmp_not(o:ocmp) : ocmp =
match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2
// Sanity check
let _ = assert (forall o . o == cmp_not (cmp_not o))
let print_first_cmp_opr (o:cmp_opr) (p:printer) =
match o with
| CReg r -> print_reg r p
| _ -> "!!! INVALID first compare operand !!! Expected general purpose register."
let print_ins (ins:ins) (p:printer) =
let print_pair (o1 o2:string) =
o1 ^ ", " ^ o2
in
let print_triple (o1 o2 o3:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3
in
let print_quadruple (o1 o2 o3 o4:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3 ^ ", " ^ o4
in
let print_reg_pair (dst src:reg) =
print_pair (print_reg dst p) (print_reg src p)
in
let print_reg_mem (o1:reg) (o2:maddr) =
print_pair (print_reg o1 p) (print_maddr o2 p)
in
let print_reg_triple (dst src1 src2:reg) =
print_triple (print_reg dst p) (print_reg src1 p) (print_reg src2 p)
in
let print_reg_imm (dst:reg) (src:int) =
print_pair (print_reg dst p) (p.const src)
in
let print_reg_pair_imm (dst src1:reg) (src2:int) =
print_triple (print_reg dst p) (print_reg src1 p) (p.const src2)
in
let print_reg_vec (dst:reg) (src:vec) (vsr:bool) =
print_pair (print_reg dst p) (print_vec src vsr p)
in
let print_vec_reg (dst:vec) (src:reg) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_reg src p)
in
let print_vec_reg_pair (dst:vec) (src1 src2:reg) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_reg src1 p) (print_reg src2 p)
in
let print_vec_pair (dst src:vec) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_vec src vsr p)
in
let print_vec_triple (dst src1 src2:vec) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p)
in
let print_vec_quadruple (dst src1 src2 src3:vec) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (print_vec src3 vsr p)
in
let print_vec_imm (dst:vec) (src:int) (vsr:bool) =
print_pair (print_vec dst vsr p) (p.const src)
in
let print_vec_pair_imm (dst src:vec) (imm:int) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src vsr p) (p.const imm)
in
let print_vec_triple_imm (dst src1 src2:vec) (count:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (p.const count)
in
let print_vec_mem (o1:vec) (o2:maddr) (vsr:bool) =
print_pair (print_vec o1 vsr p) (print_maddr o2 p)
in
let print_vec_pair_imm_pair (dst src:vec) (s0 s1:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src vsr p) (p.const s0) (p.const s1)
in
match ins with
| Move dst src -> " mr " ^ print_reg_pair dst src
| Load64 dst base offset -> " ld " ^ print_reg_mem dst ({ address = base; offset = offset })
| Store64 src base offset -> " std " ^ print_reg_mem src ({ address = base; offset = offset })
| LoadImm64 dst src -> " li " ^ print_reg_imm dst src
| LoadImmShl64 dst src -> " lis " ^ print_reg_imm dst src
| AddLa dst src1 src2 -> " la " ^ print_reg_mem dst ({ address = src1; offset = src2 })
| Add dst src1 src2 -> " add " ^ print_reg_triple dst src1 src2
| AddImm dst src1 src2 -> " addi " ^ print_reg_pair_imm dst src1 src2
| AddCarry dst src1 src2 -> " addc " ^ print_reg_triple dst src1 src2
| AddExtended dst src1 src2 -> " adde " ^ print_reg_triple dst src1 src2
| AddExtendedOV dst src1 src2 -> " addex " ^ print_reg_triple dst src1 src2
| Sub dst src1 src2 -> " sub " ^ print_reg_triple dst src1 src2
| SubImm dst src1 src2 -> " subi " ^ print_reg_pair_imm dst src1 src2
| MulLow64 dst src1 src2 -> " mulld " ^ print_reg_triple dst src1 src2
| MulHigh64U dst src1 src2 -> " mulhdu " ^ print_reg_triple dst src1 src2
| Xor dst src1 src2 -> " xor " ^ print_reg_triple dst src1 src2
| And dst src1 src2 -> " and " ^ print_reg_triple dst src1 src2
| Sr64Imm dst src1 src2 -> " srdi " ^ print_reg_pair_imm dst src1 src2
| Sl64Imm dst src1 src2 -> " sldi " ^ print_reg_pair_imm dst src1 src2
| Sr64 dst src1 src2 -> " srd " ^ print_reg_triple dst src1 src2
| Sl64 dst src1 src2 -> " sld " ^ print_reg_triple dst src1 src2
| Vmr dst src -> " vmr " ^ print_vec_pair dst src false
| Mfvsrd dst src -> " mfvsrd " ^ print_reg_vec dst src true
| Mfvsrld dst src -> " mfvsrld " ^ print_reg_vec dst src true
| Mtvsrdd dst src1 src2 -> " mtvsrdd " ^ print_vec_reg_pair dst src1 src2 true
| Mtvsrws dst src -> " mtvsrws " ^ print_vec_reg dst src true
| Vadduwm dst src1 src2 -> " vadduwm " ^ print_vec_triple dst src1 src2 false
| Vxor dst src1 src2 -> " vxor " ^ print_vec_triple dst src1 src2 false
| Vand dst src1 src2 -> " vand " ^ print_vec_triple dst src1 src2 false
| Vslw dst src1 src2 -> " vslw " ^ print_vec_triple dst src1 src2 false
| Vsrw dst src1 src2 -> " vsrw " ^ print_vec_triple dst src1 src2 false
| Vsl dst src1 src2 -> " vsl " ^ print_vec_triple dst src1 src2 false
| Vcmpequw dst src1 src2 -> " vcmpequw " ^ print_vec_triple dst src1 src2 false
| Vsldoi dst src1 src2 count -> " vsldoi " ^ print_vec_triple_imm dst src1 src2 count false
| Vmrghw dst src1 src2 -> " vmrghw " ^ print_vec_triple dst src1 src2 false
| Xxmrghd dst src1 src2 -> " xxmrghd " ^ print_vec_triple dst src1 src2 true
| Vsel dst src1 src2 sel -> " vsel " ^ print_vec_quadruple dst src1 src2 sel false
| Vspltw dst src uim -> " vspltw " ^ print_vec_pair_imm dst src uim false
| Vspltisw dst src -> " vspltisw " ^ print_vec_imm dst src false
| Vspltisb dst src -> " vspltisb " ^ print_vec_imm dst src false
| Load128 dst base offset -> " lvx " ^ print_vec_reg_pair dst offset base false
| Store128 src base offset -> " stvx " ^ print_vec_reg_pair src offset base false
| Load128Word4 dst base -> " lxvw4x " ^ print_vec_reg_pair dst 0 base true
| Load128Word4Index dst base offset -> " lxvw4x " ^ print_vec_reg_pair dst offset base true
| Store128Word4 src base -> " stxvw4x " ^ print_vec_reg_pair src 0 base true
| Store128Word4Index src base offset -> " stxvw4x " ^ print_vec_reg_pair src offset base true
| Load128Byte16 dst base -> " lxvb16x " ^ print_vec_reg_pair dst 0 base true
| Load128Byte16Index dst base offset -> " lxvb16x " ^ print_vec_reg_pair dst offset base true
| Store128Byte16 src base -> " stxvb16x " ^ print_vec_reg_pair src 0 base true
| Store128Byte16Index src base offset -> " stxvb16x " ^ print_vec_reg_pair src offset base true
| Vshasigmaw0 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 0 false
| Vshasigmaw1 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 15 false
| Vshasigmaw2 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 0 false
| Vshasigmaw3 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 15 false
| Vsbox dst src -> " vsbox " ^ print_vec_pair dst src false
| RotWord dst src1 src2 -> " vrlw " ^ print_vec_triple dst src1 src2 false
| Vcipher dst src1 src2 -> " vcipher " ^ print_vec_triple dst src1 src2 false
| Vcipherlast dst src1 src2 -> " vcipherlast " ^ print_vec_triple dst src1 src2 false
| Vncipher dst src1 src2 -> " vncipher " ^ print_vec_triple dst src1 src2 false
| Vncipherlast dst src1 src2 -> " vncipherlast " ^ print_vec_triple dst src1 src2 false
| Vpmsumd dst src1 src2 -> " vpmsumd " ^ print_vec_triple dst src1 src2 false
| Alloc n -> " subi " ^ print_reg_pair_imm 1 1 n
| Dealloc n -> " addi " ^ print_reg_pair_imm 1 1 n
| StoreStack128 src t offset -> " stxv " ^ print_vec_mem src ({ address = 1; offset = offset }) true
| LoadStack128 dst t offset -> " lxv " ^ print_vec_mem dst ({ address = 1; offset = offset }) true
| StoreStack64 src t offset -> " std " ^ print_reg_mem src ({ address = 1; offset = offset })
| LoadStack64 dst t offset -> " ld " ^ print_reg_mem dst ({ address = 1; offset = offset }) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Vale.PPC64LE.Semantics_s.ocmp -> counter: Prims.int -> p: Vale.PPC64LE.Print_s.printer
-> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Semantics_s.ocmp",
"Prims.int",
"Vale.PPC64LE.Print_s.printer",
"Vale.PPC64LE.Machine_s.cmp_opr",
"Prims.op_Hat",
"Prims.string_of_int",
"Prims.string",
"Vale.PPC64LE.Machine_s.reg",
"Vale.PPC64LE.Print_s.print_first_cmp_opr",
"Vale.PPC64LE.Print_s.print_reg",
"Vale.PPC64LE.Machine_s.imm16"
] | [] | false | false | false | true | false | let print_cmp (c: ocmp) (counter: int) (p: printer) : string =
| let print_cmp_ops (o1 o2: cmp_opr) : string =
match o2 with
| CReg r -> " cmpld " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (print_reg r p) ^ "\n"
| CImm n -> " cmpldi " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (string_of_int n) ^ "\n"
in
match c with
| OEq o1 o2 -> print_cmp_ops o1 o2 ^ " beq " ^ "L" ^ string_of_int counter ^ "\n"
| ONe o1 o2 -> print_cmp_ops o1 o2 ^ " bne " ^ "L" ^ string_of_int counter ^ "\n"
| OLe o1 o2 -> print_cmp_ops o1 o2 ^ " ble " ^ "L" ^ string_of_int counter ^ "\n"
| OGe o1 o2 -> print_cmp_ops o1 o2 ^ " bge " ^ "L" ^ string_of_int counter ^ "\n"
| OLt o1 o2 -> print_cmp_ops o1 o2 ^ " blt " ^ "L" ^ string_of_int counter ^ "\n"
| OGt o1 o2 -> print_cmp_ops o1 o2 ^ " bgt " ^ "L" ^ string_of_int counter ^ "\n" | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.store_state | val store_state (a: sha2_alg) (hashw: words_state a) : Tot (lseq uint8 (8 * word_length a)) | val store_state (a: sha2_alg) (hashw: words_state a) : Tot (lseq uint8 (8 * word_length a)) | let store_state (a:sha2_alg) (hashw:words_state a) : Tot (lseq uint8 (8 * word_length a)) =
Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 267,
"start_col": 0,
"start_line": 266
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2
let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1)
let update_last (a:sha2_alg) (totlen:len_t a)
(len:nat{len <= block_length a})
(b:bytes{S.length b = len}) (hash:words_state a) : Tot (words_state a) =
let blocks = padded_blocks a len in
let fin = blocks * block_length a in
let total_len_bits = secret (shift_left #(len_int_type a) totlen 3ul) in
let totlen_seq = Lib.ByteSequence.uint_to_bytes_be #(len_int_type a) total_len_bits in
let (b0, b1) = load_last a totlen_seq fin len b in
let hash = update a b0 hash in
if blocks > 1 then update a b1 hash else hash | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.sha2_alg -> hashw: Spec.Hash.Definitions.words_state a
-> Lib.Sequence.lseq Lib.IntTypes.uint8 (8 * Spec.Hash.Definitions.word_length a) | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.words_state",
"Lib.ByteSequence.uints_to_bytes_be",
"Spec.Hash.Definitions.word_t",
"Lib.IntTypes.SEC",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"FStar.Mul.op_Star",
"Spec.Hash.Definitions.word_length"
] | [] | false | false | false | false | false | let store_state (a: sha2_alg) (hashw: words_state a) : Tot (lseq uint8 (8 * word_length a)) =
| Lib.ByteSequence.uints_to_bytes_be #(word_t a) #SEC #8 hashw | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_block | val print_block (b: codes) (n: int) (p: printer) : string & int | val print_block (b: codes) (n: int) (p: printer) : string & int | let rec print_block (b:codes) (n:int) (p:printer) : string & int =
match b with
| Nil -> ("", n)
| head :: tail ->
let (head_str, n') = print_code head n p in
let (rest, n'') = print_block tail n' p in
(head_str ^ rest, n'')
and print_code (c:code) (n:int) (p:printer) : string & int =
match c with
| Ins ins -> (print_ins ins p ^ "\n", n)
| Block b -> print_block b n p
| IfElse cond true_code false_code ->
let n1 = n in
let n2 = n + 1 in
let cmp = print_cmp (cmp_not cond) n1 p in
let (true_str, n') = print_code true_code (n + 2) p in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = "L" ^ string_of_int n1 ^ ":\n" in
let (false_str, n') = print_code false_code n' p in
let label2 = "L" ^ string_of_int n2 ^ ":\n" in
(cmp ^ true_str ^ branch ^ label1 ^ false_str ^ label2, n')
| While cond body ->
let n1 = n in
let n2 = n + 1 in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = p.align() ^ " 4\nL" ^ string_of_int n1 ^ ":\n" in
let (body_str, n') = print_code body (n + 2) p in
let label2 = p.align() ^ " 4\nL" ^ string_of_int n2 ^ ":\n" in
let cmp = print_cmp cond n1 p in
(branch ^ label1 ^ body_str ^ label2 ^ cmp, n') | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 219,
"start_col": 0,
"start_line": 190
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v
let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p)
let cmp_not(o:ocmp) : ocmp =
match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2
// Sanity check
let _ = assert (forall o . o == cmp_not (cmp_not o))
let print_first_cmp_opr (o:cmp_opr) (p:printer) =
match o with
| CReg r -> print_reg r p
| _ -> "!!! INVALID first compare operand !!! Expected general purpose register."
let print_ins (ins:ins) (p:printer) =
let print_pair (o1 o2:string) =
o1 ^ ", " ^ o2
in
let print_triple (o1 o2 o3:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3
in
let print_quadruple (o1 o2 o3 o4:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3 ^ ", " ^ o4
in
let print_reg_pair (dst src:reg) =
print_pair (print_reg dst p) (print_reg src p)
in
let print_reg_mem (o1:reg) (o2:maddr) =
print_pair (print_reg o1 p) (print_maddr o2 p)
in
let print_reg_triple (dst src1 src2:reg) =
print_triple (print_reg dst p) (print_reg src1 p) (print_reg src2 p)
in
let print_reg_imm (dst:reg) (src:int) =
print_pair (print_reg dst p) (p.const src)
in
let print_reg_pair_imm (dst src1:reg) (src2:int) =
print_triple (print_reg dst p) (print_reg src1 p) (p.const src2)
in
let print_reg_vec (dst:reg) (src:vec) (vsr:bool) =
print_pair (print_reg dst p) (print_vec src vsr p)
in
let print_vec_reg (dst:vec) (src:reg) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_reg src p)
in
let print_vec_reg_pair (dst:vec) (src1 src2:reg) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_reg src1 p) (print_reg src2 p)
in
let print_vec_pair (dst src:vec) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_vec src vsr p)
in
let print_vec_triple (dst src1 src2:vec) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p)
in
let print_vec_quadruple (dst src1 src2 src3:vec) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (print_vec src3 vsr p)
in
let print_vec_imm (dst:vec) (src:int) (vsr:bool) =
print_pair (print_vec dst vsr p) (p.const src)
in
let print_vec_pair_imm (dst src:vec) (imm:int) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src vsr p) (p.const imm)
in
let print_vec_triple_imm (dst src1 src2:vec) (count:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (p.const count)
in
let print_vec_mem (o1:vec) (o2:maddr) (vsr:bool) =
print_pair (print_vec o1 vsr p) (print_maddr o2 p)
in
let print_vec_pair_imm_pair (dst src:vec) (s0 s1:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src vsr p) (p.const s0) (p.const s1)
in
match ins with
| Move dst src -> " mr " ^ print_reg_pair dst src
| Load64 dst base offset -> " ld " ^ print_reg_mem dst ({ address = base; offset = offset })
| Store64 src base offset -> " std " ^ print_reg_mem src ({ address = base; offset = offset })
| LoadImm64 dst src -> " li " ^ print_reg_imm dst src
| LoadImmShl64 dst src -> " lis " ^ print_reg_imm dst src
| AddLa dst src1 src2 -> " la " ^ print_reg_mem dst ({ address = src1; offset = src2 })
| Add dst src1 src2 -> " add " ^ print_reg_triple dst src1 src2
| AddImm dst src1 src2 -> " addi " ^ print_reg_pair_imm dst src1 src2
| AddCarry dst src1 src2 -> " addc " ^ print_reg_triple dst src1 src2
| AddExtended dst src1 src2 -> " adde " ^ print_reg_triple dst src1 src2
| AddExtendedOV dst src1 src2 -> " addex " ^ print_reg_triple dst src1 src2
| Sub dst src1 src2 -> " sub " ^ print_reg_triple dst src1 src2
| SubImm dst src1 src2 -> " subi " ^ print_reg_pair_imm dst src1 src2
| MulLow64 dst src1 src2 -> " mulld " ^ print_reg_triple dst src1 src2
| MulHigh64U dst src1 src2 -> " mulhdu " ^ print_reg_triple dst src1 src2
| Xor dst src1 src2 -> " xor " ^ print_reg_triple dst src1 src2
| And dst src1 src2 -> " and " ^ print_reg_triple dst src1 src2
| Sr64Imm dst src1 src2 -> " srdi " ^ print_reg_pair_imm dst src1 src2
| Sl64Imm dst src1 src2 -> " sldi " ^ print_reg_pair_imm dst src1 src2
| Sr64 dst src1 src2 -> " srd " ^ print_reg_triple dst src1 src2
| Sl64 dst src1 src2 -> " sld " ^ print_reg_triple dst src1 src2
| Vmr dst src -> " vmr " ^ print_vec_pair dst src false
| Mfvsrd dst src -> " mfvsrd " ^ print_reg_vec dst src true
| Mfvsrld dst src -> " mfvsrld " ^ print_reg_vec dst src true
| Mtvsrdd dst src1 src2 -> " mtvsrdd " ^ print_vec_reg_pair dst src1 src2 true
| Mtvsrws dst src -> " mtvsrws " ^ print_vec_reg dst src true
| Vadduwm dst src1 src2 -> " vadduwm " ^ print_vec_triple dst src1 src2 false
| Vxor dst src1 src2 -> " vxor " ^ print_vec_triple dst src1 src2 false
| Vand dst src1 src2 -> " vand " ^ print_vec_triple dst src1 src2 false
| Vslw dst src1 src2 -> " vslw " ^ print_vec_triple dst src1 src2 false
| Vsrw dst src1 src2 -> " vsrw " ^ print_vec_triple dst src1 src2 false
| Vsl dst src1 src2 -> " vsl " ^ print_vec_triple dst src1 src2 false
| Vcmpequw dst src1 src2 -> " vcmpequw " ^ print_vec_triple dst src1 src2 false
| Vsldoi dst src1 src2 count -> " vsldoi " ^ print_vec_triple_imm dst src1 src2 count false
| Vmrghw dst src1 src2 -> " vmrghw " ^ print_vec_triple dst src1 src2 false
| Xxmrghd dst src1 src2 -> " xxmrghd " ^ print_vec_triple dst src1 src2 true
| Vsel dst src1 src2 sel -> " vsel " ^ print_vec_quadruple dst src1 src2 sel false
| Vspltw dst src uim -> " vspltw " ^ print_vec_pair_imm dst src uim false
| Vspltisw dst src -> " vspltisw " ^ print_vec_imm dst src false
| Vspltisb dst src -> " vspltisb " ^ print_vec_imm dst src false
| Load128 dst base offset -> " lvx " ^ print_vec_reg_pair dst offset base false
| Store128 src base offset -> " stvx " ^ print_vec_reg_pair src offset base false
| Load128Word4 dst base -> " lxvw4x " ^ print_vec_reg_pair dst 0 base true
| Load128Word4Index dst base offset -> " lxvw4x " ^ print_vec_reg_pair dst offset base true
| Store128Word4 src base -> " stxvw4x " ^ print_vec_reg_pair src 0 base true
| Store128Word4Index src base offset -> " stxvw4x " ^ print_vec_reg_pair src offset base true
| Load128Byte16 dst base -> " lxvb16x " ^ print_vec_reg_pair dst 0 base true
| Load128Byte16Index dst base offset -> " lxvb16x " ^ print_vec_reg_pair dst offset base true
| Store128Byte16 src base -> " stxvb16x " ^ print_vec_reg_pair src 0 base true
| Store128Byte16Index src base offset -> " stxvb16x " ^ print_vec_reg_pair src offset base true
| Vshasigmaw0 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 0 false
| Vshasigmaw1 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 15 false
| Vshasigmaw2 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 0 false
| Vshasigmaw3 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 15 false
| Vsbox dst src -> " vsbox " ^ print_vec_pair dst src false
| RotWord dst src1 src2 -> " vrlw " ^ print_vec_triple dst src1 src2 false
| Vcipher dst src1 src2 -> " vcipher " ^ print_vec_triple dst src1 src2 false
| Vcipherlast dst src1 src2 -> " vcipherlast " ^ print_vec_triple dst src1 src2 false
| Vncipher dst src1 src2 -> " vncipher " ^ print_vec_triple dst src1 src2 false
| Vncipherlast dst src1 src2 -> " vncipherlast " ^ print_vec_triple dst src1 src2 false
| Vpmsumd dst src1 src2 -> " vpmsumd " ^ print_vec_triple dst src1 src2 false
| Alloc n -> " subi " ^ print_reg_pair_imm 1 1 n
| Dealloc n -> " addi " ^ print_reg_pair_imm 1 1 n
| StoreStack128 src t offset -> " stxv " ^ print_vec_mem src ({ address = 1; offset = offset }) true
| LoadStack128 dst t offset -> " lxv " ^ print_vec_mem dst ({ address = 1; offset = offset }) true
| StoreStack64 src t offset -> " std " ^ print_reg_mem src ({ address = 1; offset = offset })
| LoadStack64 dst t offset -> " ld " ^ print_reg_mem dst ({ address = 1; offset = offset })
| Ghost _ -> ""
let print_cmp (c:ocmp) (counter:int) (p:printer) : string =
let print_cmp_ops (o1:cmp_opr) (o2:cmp_opr) : string =
match o2 with
| CReg r -> " cmpld " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (print_reg r p) ^ "\n"
| CImm n -> " cmpldi " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (string_of_int n) ^ "\n"
in
match c with
| OEq o1 o2 -> print_cmp_ops o1 o2 ^ " beq " ^ "L" ^ string_of_int counter ^ "\n"
| ONe o1 o2 -> print_cmp_ops o1 o2 ^ " bne "^ "L" ^ string_of_int counter ^ "\n"
| OLe o1 o2 -> print_cmp_ops o1 o2 ^ " ble "^ "L" ^ string_of_int counter ^ "\n"
| OGe o1 o2 -> print_cmp_ops o1 o2 ^ " bge "^ "L" ^ string_of_int counter ^ "\n"
| OLt o1 o2 -> print_cmp_ops o1 o2 ^ " blt " ^ "L" ^ string_of_int counter ^ "\n"
| OGt o1 o2 -> print_cmp_ops o1 o2 ^ " bgt " ^ "L" ^ string_of_int counter ^ "\n" | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: Vale.PPC64LE.Semantics_s.codes -> n: Prims.int -> p: Vale.PPC64LE.Print_s.printer
-> Prims.string * Prims.int | Prims.Tot | [
"total"
] | [
"print_block",
"print_code"
] | [
"Vale.PPC64LE.Semantics_s.codes",
"Prims.int",
"Vale.PPC64LE.Print_s.printer",
"FStar.Pervasives.Native.Mktuple2",
"Prims.string",
"Vale.PPC64LE.Semantics_s.code",
"Prims.list",
"Prims.op_Hat",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Print_s.print_block",
"Vale.PPC64LE.Print_s.print_code"
] | [
"mutual recursion"
] | false | false | false | true | false | let rec print_block (b: codes) (n: int) (p: printer) : string & int =
| match b with
| Nil -> ("", n)
| head :: tail ->
let head_str, n' = print_code head n p in
let rest, n'' = print_block tail n' p in
(head_str ^ rest, n'') | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_ins | val print_ins : ins: Vale.PPC64LE.Semantics_s.ins -> p: Vale.PPC64LE.Print_s.printer -> Prims.string | let print_ins (ins:ins) (p:printer) =
let print_pair (o1 o2:string) =
o1 ^ ", " ^ o2
in
let print_triple (o1 o2 o3:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3
in
let print_quadruple (o1 o2 o3 o4:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3 ^ ", " ^ o4
in
let print_reg_pair (dst src:reg) =
print_pair (print_reg dst p) (print_reg src p)
in
let print_reg_mem (o1:reg) (o2:maddr) =
print_pair (print_reg o1 p) (print_maddr o2 p)
in
let print_reg_triple (dst src1 src2:reg) =
print_triple (print_reg dst p) (print_reg src1 p) (print_reg src2 p)
in
let print_reg_imm (dst:reg) (src:int) =
print_pair (print_reg dst p) (p.const src)
in
let print_reg_pair_imm (dst src1:reg) (src2:int) =
print_triple (print_reg dst p) (print_reg src1 p) (p.const src2)
in
let print_reg_vec (dst:reg) (src:vec) (vsr:bool) =
print_pair (print_reg dst p) (print_vec src vsr p)
in
let print_vec_reg (dst:vec) (src:reg) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_reg src p)
in
let print_vec_reg_pair (dst:vec) (src1 src2:reg) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_reg src1 p) (print_reg src2 p)
in
let print_vec_pair (dst src:vec) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_vec src vsr p)
in
let print_vec_triple (dst src1 src2:vec) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p)
in
let print_vec_quadruple (dst src1 src2 src3:vec) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (print_vec src3 vsr p)
in
let print_vec_imm (dst:vec) (src:int) (vsr:bool) =
print_pair (print_vec dst vsr p) (p.const src)
in
let print_vec_pair_imm (dst src:vec) (imm:int) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src vsr p) (p.const imm)
in
let print_vec_triple_imm (dst src1 src2:vec) (count:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (p.const count)
in
let print_vec_mem (o1:vec) (o2:maddr) (vsr:bool) =
print_pair (print_vec o1 vsr p) (print_maddr o2 p)
in
let print_vec_pair_imm_pair (dst src:vec) (s0 s1:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src vsr p) (p.const s0) (p.const s1)
in
match ins with
| Move dst src -> " mr " ^ print_reg_pair dst src
| Load64 dst base offset -> " ld " ^ print_reg_mem dst ({ address = base; offset = offset })
| Store64 src base offset -> " std " ^ print_reg_mem src ({ address = base; offset = offset })
| LoadImm64 dst src -> " li " ^ print_reg_imm dst src
| LoadImmShl64 dst src -> " lis " ^ print_reg_imm dst src
| AddLa dst src1 src2 -> " la " ^ print_reg_mem dst ({ address = src1; offset = src2 })
| Add dst src1 src2 -> " add " ^ print_reg_triple dst src1 src2
| AddImm dst src1 src2 -> " addi " ^ print_reg_pair_imm dst src1 src2
| AddCarry dst src1 src2 -> " addc " ^ print_reg_triple dst src1 src2
| AddExtended dst src1 src2 -> " adde " ^ print_reg_triple dst src1 src2
| AddExtendedOV dst src1 src2 -> " addex " ^ print_reg_triple dst src1 src2
| Sub dst src1 src2 -> " sub " ^ print_reg_triple dst src1 src2
| SubImm dst src1 src2 -> " subi " ^ print_reg_pair_imm dst src1 src2
| MulLow64 dst src1 src2 -> " mulld " ^ print_reg_triple dst src1 src2
| MulHigh64U dst src1 src2 -> " mulhdu " ^ print_reg_triple dst src1 src2
| Xor dst src1 src2 -> " xor " ^ print_reg_triple dst src1 src2
| And dst src1 src2 -> " and " ^ print_reg_triple dst src1 src2
| Sr64Imm dst src1 src2 -> " srdi " ^ print_reg_pair_imm dst src1 src2
| Sl64Imm dst src1 src2 -> " sldi " ^ print_reg_pair_imm dst src1 src2
| Sr64 dst src1 src2 -> " srd " ^ print_reg_triple dst src1 src2
| Sl64 dst src1 src2 -> " sld " ^ print_reg_triple dst src1 src2
| Vmr dst src -> " vmr " ^ print_vec_pair dst src false
| Mfvsrd dst src -> " mfvsrd " ^ print_reg_vec dst src true
| Mfvsrld dst src -> " mfvsrld " ^ print_reg_vec dst src true
| Mtvsrdd dst src1 src2 -> " mtvsrdd " ^ print_vec_reg_pair dst src1 src2 true
| Mtvsrws dst src -> " mtvsrws " ^ print_vec_reg dst src true
| Vadduwm dst src1 src2 -> " vadduwm " ^ print_vec_triple dst src1 src2 false
| Vxor dst src1 src2 -> " vxor " ^ print_vec_triple dst src1 src2 false
| Vand dst src1 src2 -> " vand " ^ print_vec_triple dst src1 src2 false
| Vslw dst src1 src2 -> " vslw " ^ print_vec_triple dst src1 src2 false
| Vsrw dst src1 src2 -> " vsrw " ^ print_vec_triple dst src1 src2 false
| Vsl dst src1 src2 -> " vsl " ^ print_vec_triple dst src1 src2 false
| Vcmpequw dst src1 src2 -> " vcmpequw " ^ print_vec_triple dst src1 src2 false
| Vsldoi dst src1 src2 count -> " vsldoi " ^ print_vec_triple_imm dst src1 src2 count false
| Vmrghw dst src1 src2 -> " vmrghw " ^ print_vec_triple dst src1 src2 false
| Xxmrghd dst src1 src2 -> " xxmrghd " ^ print_vec_triple dst src1 src2 true
| Vsel dst src1 src2 sel -> " vsel " ^ print_vec_quadruple dst src1 src2 sel false
| Vspltw dst src uim -> " vspltw " ^ print_vec_pair_imm dst src uim false
| Vspltisw dst src -> " vspltisw " ^ print_vec_imm dst src false
| Vspltisb dst src -> " vspltisb " ^ print_vec_imm dst src false
| Load128 dst base offset -> " lvx " ^ print_vec_reg_pair dst offset base false
| Store128 src base offset -> " stvx " ^ print_vec_reg_pair src offset base false
| Load128Word4 dst base -> " lxvw4x " ^ print_vec_reg_pair dst 0 base true
| Load128Word4Index dst base offset -> " lxvw4x " ^ print_vec_reg_pair dst offset base true
| Store128Word4 src base -> " stxvw4x " ^ print_vec_reg_pair src 0 base true
| Store128Word4Index src base offset -> " stxvw4x " ^ print_vec_reg_pair src offset base true
| Load128Byte16 dst base -> " lxvb16x " ^ print_vec_reg_pair dst 0 base true
| Load128Byte16Index dst base offset -> " lxvb16x " ^ print_vec_reg_pair dst offset base true
| Store128Byte16 src base -> " stxvb16x " ^ print_vec_reg_pair src 0 base true
| Store128Byte16Index src base offset -> " stxvb16x " ^ print_vec_reg_pair src offset base true
| Vshasigmaw0 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 0 false
| Vshasigmaw1 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 15 false
| Vshasigmaw2 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 0 false
| Vshasigmaw3 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 15 false
| Vsbox dst src -> " vsbox " ^ print_vec_pair dst src false
| RotWord dst src1 src2 -> " vrlw " ^ print_vec_triple dst src1 src2 false
| Vcipher dst src1 src2 -> " vcipher " ^ print_vec_triple dst src1 src2 false
| Vcipherlast dst src1 src2 -> " vcipherlast " ^ print_vec_triple dst src1 src2 false
| Vncipher dst src1 src2 -> " vncipher " ^ print_vec_triple dst src1 src2 false
| Vncipherlast dst src1 src2 -> " vncipherlast " ^ print_vec_triple dst src1 src2 false
| Vpmsumd dst src1 src2 -> " vpmsumd " ^ print_vec_triple dst src1 src2 false
| Alloc n -> " subi " ^ print_reg_pair_imm 1 1 n
| Dealloc n -> " addi " ^ print_reg_pair_imm 1 1 n
| StoreStack128 src t offset -> " stxv " ^ print_vec_mem src ({ address = 1; offset = offset }) true
| LoadStack128 dst t offset -> " lxv " ^ print_vec_mem dst ({ address = 1; offset = offset }) true
| StoreStack64 src t offset -> " std " ^ print_reg_mem src ({ address = 1; offset = offset })
| LoadStack64 dst t offset -> " ld " ^ print_reg_mem dst ({ address = 1; offset = offset })
| Ghost _ -> "" | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 175,
"start_col": 0,
"start_line": 49
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v
let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p)
let cmp_not(o:ocmp) : ocmp =
match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2
// Sanity check
let _ = assert (forall o . o == cmp_not (cmp_not o))
let print_first_cmp_opr (o:cmp_opr) (p:printer) =
match o with
| CReg r -> print_reg r p
| _ -> "!!! INVALID first compare operand !!! Expected general purpose register." | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ins: Vale.PPC64LE.Semantics_s.ins -> p: Vale.PPC64LE.Print_s.printer -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Semantics_s.ins",
"Vale.PPC64LE.Print_s.printer",
"Vale.PPC64LE.Machine_s.reg",
"Prims.op_Hat",
"Prims.int",
"Vale.PPC64LE.Machine_s.Mkmaddr",
"Vale.PPC64LE.Machine_s.simm16",
"Vale.PPC64LE.Machine_s.nsimm16",
"Vale.PPC64LE.Machine_s.bits64",
"Vale.PPC64LE.Machine_s.vec",
"Vale.PPC64LE.Machine_s.quad32bytes",
"Vale.Def.Words_s.nat2",
"Vale.PPC64LE.Machine_s.sim",
"Vale.Def.Types_s.nat64",
"Vale.Arch.HeapTypes_s.taint",
"Prims.unit",
"Prims.string",
"Prims.bool",
"Vale.PPC64LE.Print_s.print_vec",
"Vale.PPC64LE.Print_s.__proj__Mkprinter__item__const",
"Vale.PPC64LE.Machine_s.maddr",
"Vale.PPC64LE.Print_s.print_maddr",
"Vale.PPC64LE.Print_s.print_reg"
] | [] | false | false | false | true | false | let print_ins (ins: ins) (p: printer) =
| let print_pair (o1 o2: string) = o1 ^ ", " ^ o2 in
let print_triple (o1 o2 o3: string) = o1 ^ ", " ^ o2 ^ ", " ^ o3 in
let print_quadruple (o1 o2 o3 o4: string) = o1 ^ ", " ^ o2 ^ ", " ^ o3 ^ ", " ^ o4 in
let print_reg_pair (dst src: reg) = print_pair (print_reg dst p) (print_reg src p) in
let print_reg_mem (o1: reg) (o2: maddr) = print_pair (print_reg o1 p) (print_maddr o2 p) in
let print_reg_triple (dst src1 src2: reg) =
print_triple (print_reg dst p) (print_reg src1 p) (print_reg src2 p)
in
let print_reg_imm (dst: reg) (src: int) = print_pair (print_reg dst p) (p.const src) in
let print_reg_pair_imm (dst src1: reg) (src2: int) =
print_triple (print_reg dst p) (print_reg src1 p) (p.const src2)
in
let print_reg_vec (dst: reg) (src: vec) (vsr: bool) =
print_pair (print_reg dst p) (print_vec src vsr p)
in
let print_vec_reg (dst: vec) (src: reg) (vsr: bool) =
print_pair (print_vec dst vsr p) (print_reg src p)
in
let print_vec_reg_pair (dst: vec) (src1 src2: reg) (vsr: bool) =
print_triple (print_vec dst vsr p) (print_reg src1 p) (print_reg src2 p)
in
let print_vec_pair (dst src: vec) (vsr: bool) =
print_pair (print_vec dst vsr p) (print_vec src vsr p)
in
let print_vec_triple (dst src1 src2: vec) (vsr: bool) =
print_triple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p)
in
let print_vec_quadruple (dst src1 src2 src3: vec) (vsr: bool) =
print_quadruple (print_vec dst vsr p)
(print_vec src1 vsr p)
(print_vec src2 vsr p)
(print_vec src3 vsr p)
in
let print_vec_imm (dst: vec) (src: int) (vsr: bool) =
print_pair (print_vec dst vsr p) (p.const src)
in
let print_vec_pair_imm (dst src: vec) (imm: int) (vsr: bool) =
print_triple (print_vec dst vsr p) (print_vec src vsr p) (p.const imm)
in
let print_vec_triple_imm (dst src1 src2: vec) (count: int) (vsr: bool) =
print_quadruple (print_vec dst vsr p)
(print_vec src1 vsr p)
(print_vec src2 vsr p)
(p.const count)
in
let print_vec_mem (o1: vec) (o2: maddr) (vsr: bool) =
print_pair (print_vec o1 vsr p) (print_maddr o2 p)
in
let print_vec_pair_imm_pair (dst src: vec) (s0 s1: int) (vsr: bool) =
print_quadruple (print_vec dst vsr p) (print_vec src vsr p) (p.const s0) (p.const s1)
in
match ins with
| Move dst src -> " mr " ^ print_reg_pair dst src
| Load64 dst base offset -> " ld " ^ print_reg_mem dst ({ address = base; offset = offset })
| Store64 src base offset -> " std " ^ print_reg_mem src ({ address = base; offset = offset })
| LoadImm64 dst src -> " li " ^ print_reg_imm dst src
| LoadImmShl64 dst src -> " lis " ^ print_reg_imm dst src
| AddLa dst src1 src2 -> " la " ^ print_reg_mem dst ({ address = src1; offset = src2 })
| Add dst src1 src2 -> " add " ^ print_reg_triple dst src1 src2
| AddImm dst src1 src2 -> " addi " ^ print_reg_pair_imm dst src1 src2
| AddCarry dst src1 src2 -> " addc " ^ print_reg_triple dst src1 src2
| AddExtended dst src1 src2 -> " adde " ^ print_reg_triple dst src1 src2
| AddExtendedOV dst src1 src2 -> " addex " ^ print_reg_triple dst src1 src2
| Sub dst src1 src2 -> " sub " ^ print_reg_triple dst src1 src2
| SubImm dst src1 src2 -> " subi " ^ print_reg_pair_imm dst src1 src2
| MulLow64 dst src1 src2 -> " mulld " ^ print_reg_triple dst src1 src2
| MulHigh64U dst src1 src2 -> " mulhdu " ^ print_reg_triple dst src1 src2
| Xor dst src1 src2 -> " xor " ^ print_reg_triple dst src1 src2
| And dst src1 src2 -> " and " ^ print_reg_triple dst src1 src2
| Sr64Imm dst src1 src2 -> " srdi " ^ print_reg_pair_imm dst src1 src2
| Sl64Imm dst src1 src2 -> " sldi " ^ print_reg_pair_imm dst src1 src2
| Sr64 dst src1 src2 -> " srd " ^ print_reg_triple dst src1 src2
| Sl64 dst src1 src2 -> " sld " ^ print_reg_triple dst src1 src2
| Vmr dst src -> " vmr " ^ print_vec_pair dst src false
| Mfvsrd dst src -> " mfvsrd " ^ print_reg_vec dst src true
| Mfvsrld dst src -> " mfvsrld " ^ print_reg_vec dst src true
| Mtvsrdd dst src1 src2 -> " mtvsrdd " ^ print_vec_reg_pair dst src1 src2 true
| Mtvsrws dst src -> " mtvsrws " ^ print_vec_reg dst src true
| Vadduwm dst src1 src2 -> " vadduwm " ^ print_vec_triple dst src1 src2 false
| Vxor dst src1 src2 -> " vxor " ^ print_vec_triple dst src1 src2 false
| Vand dst src1 src2 -> " vand " ^ print_vec_triple dst src1 src2 false
| Vslw dst src1 src2 -> " vslw " ^ print_vec_triple dst src1 src2 false
| Vsrw dst src1 src2 -> " vsrw " ^ print_vec_triple dst src1 src2 false
| Vsl dst src1 src2 -> " vsl " ^ print_vec_triple dst src1 src2 false
| Vcmpequw dst src1 src2 -> " vcmpequw " ^ print_vec_triple dst src1 src2 false
| Vsldoi dst src1 src2 count -> " vsldoi " ^ print_vec_triple_imm dst src1 src2 count false
| Vmrghw dst src1 src2 -> " vmrghw " ^ print_vec_triple dst src1 src2 false
| Xxmrghd dst src1 src2 -> " xxmrghd " ^ print_vec_triple dst src1 src2 true
| Vsel dst src1 src2 sel -> " vsel " ^ print_vec_quadruple dst src1 src2 sel false
| Vspltw dst src uim -> " vspltw " ^ print_vec_pair_imm dst src uim false
| Vspltisw dst src -> " vspltisw " ^ print_vec_imm dst src false
| Vspltisb dst src -> " vspltisb " ^ print_vec_imm dst src false
| Load128 dst base offset -> " lvx " ^ print_vec_reg_pair dst offset base false
| Store128 src base offset -> " stvx " ^ print_vec_reg_pair src offset base false
| Load128Word4 dst base -> " lxvw4x " ^ print_vec_reg_pair dst 0 base true
| Load128Word4Index dst base offset -> " lxvw4x " ^ print_vec_reg_pair dst offset base true
| Store128Word4 src base -> " stxvw4x " ^ print_vec_reg_pair src 0 base true
| Store128Word4Index src base offset -> " stxvw4x " ^ print_vec_reg_pair src offset base true
| Load128Byte16 dst base -> " lxvb16x " ^ print_vec_reg_pair dst 0 base true
| Load128Byte16Index dst base offset -> " lxvb16x " ^ print_vec_reg_pair dst offset base true
| Store128Byte16 src base -> " stxvb16x " ^ print_vec_reg_pair src 0 base true
| Store128Byte16Index src base offset -> " stxvb16x " ^ print_vec_reg_pair src offset base true
| Vshasigmaw0 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 0 false
| Vshasigmaw1 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 15 false
| Vshasigmaw2 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 0 false
| Vshasigmaw3 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 15 false
| Vsbox dst src -> " vsbox " ^ print_vec_pair dst src false
| RotWord dst src1 src2 -> " vrlw " ^ print_vec_triple dst src1 src2 false
| Vcipher dst src1 src2 -> " vcipher " ^ print_vec_triple dst src1 src2 false
| Vcipherlast dst src1 src2 -> " vcipherlast " ^ print_vec_triple dst src1 src2 false
| Vncipher dst src1 src2 -> " vncipher " ^ print_vec_triple dst src1 src2 false
| Vncipherlast dst src1 src2 -> " vncipherlast " ^ print_vec_triple dst src1 src2 false
| Vpmsumd dst src1 src2 -> " vpmsumd " ^ print_vec_triple dst src1 src2 false
| Alloc n -> " subi " ^ print_reg_pair_imm 1 1 n
| Dealloc n -> " addi " ^ print_reg_pair_imm 1 1 n
| StoreStack128 src t offset ->
" stxv " ^ print_vec_mem src ({ address = 1; offset = offset }) true
| LoadStack128 dst t offset -> " lxv " ^ print_vec_mem dst ({ address = 1; offset = offset }) true
| StoreStack64 src t offset -> " std " ^ print_reg_mem src ({ address = 1; offset = offset })
| LoadStack64 dst t offset -> " ld " ^ print_reg_mem dst ({ address = 1; offset = offset })
| Ghost _ -> "" | false |
|
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.cmp_not | val cmp_not (o: ocmp) : ocmp | val cmp_not (o: ocmp) : ocmp | let cmp_not(o:ocmp) : ocmp =
match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2 | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 39,
"start_col": 0,
"start_line": 32
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v
let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | o: Vale.PPC64LE.Semantics_s.ocmp -> Vale.PPC64LE.Semantics_s.ocmp | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.Semantics_s.ocmp",
"Vale.PPC64LE.Machine_s.cmp_opr",
"Vale.PPC64LE.Semantics_s.ONe",
"Vale.PPC64LE.Semantics_s.OEq",
"Vale.PPC64LE.Semantics_s.OGt",
"Vale.PPC64LE.Semantics_s.OLt",
"Vale.PPC64LE.Semantics_s.OGe",
"Vale.PPC64LE.Semantics_s.OLe"
] | [] | false | false | false | true | false | let cmp_not (o: ocmp) : ocmp =
| match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2 | false |
Hacl.Spec.SHA2.fst | Hacl.Spec.SHA2.load_last | val load_last
(a: sha2_alg)
(totlen_seq: lseq uint8 (len_length a))
(fin: nat{fin == block_length a \/ fin == 2 * block_length a})
(len: nat{len <= block_length a})
(b: bytes{S.length b = len})
: (block_t a & block_t a) | val load_last
(a: sha2_alg)
(totlen_seq: lseq uint8 (len_length a))
(fin: nat{fin == block_length a \/ fin == 2 * block_length a})
(len: nat{len <= block_length a})
(b: bytes{S.length b = len})
: (block_t a & block_t a) | let load_last (a:sha2_alg) (totlen_seq:lseq uint8 (len_length a))
(fin:nat{fin == block_length a \/ fin == 2 * block_length a})
(len:nat{len <= block_length a}) (b:bytes{S.length b = len}) :
(block_t a & block_t a)
=
let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[len] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1) | {
"file_name": "code/sha2-mb/Hacl.Spec.SHA2.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 10,
"end_line": 251,
"start_col": 0,
"start_line": 240
} | module Hacl.Spec.SHA2
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module C = Spec.SHA2.Constants
module S = FStar.Seq
open Spec.Hash.Definitions
#set-options "--z3rlimit 20 --fuel 0 --ifuel 0"
let len_lt_max_a_t (a:sha2_alg) = len:nat{len `less_than_max_input_length` a}
let mk_len_t (a:sha2_alg) (len:len_lt_max_a_t a) : len_t a =
match a with
| SHA2_224 | SHA2_256 ->
(Math.Lemmas.pow2_lt_compat 64 61; uint #U64 #PUB len)
| SHA2_384 | SHA2_512 ->
(Math.Lemmas.pow2_lt_compat 128 125; uint #U128 #PUB len)
(* The core compression, padding and extraction functions for all SHA2
* algorithms. *)
(* Define the length of the constants. Also the number of scheduling rounds. *)
inline_for_extraction
let size_k_w: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 64
| SHA2_384 | SHA2_512 -> 80
inline_for_extraction
let word_n: sha2_alg -> Tot nat = function
| SHA2_224 | SHA2_256 -> 32
| SHA2_384 | SHA2_512 -> 64
inline_for_extraction
let to_word (a:sha2_alg) (n:nat{n < pow2 (word_n a)}) : word a =
match a with
| SHA2_224 | SHA2_256 -> u32 n
| SHA2_384 | SHA2_512 -> u64 n
inline_for_extraction
let num_rounds16 (a:sha2_alg) : n:pos{16 * n == size_k_w a} =
match a with
| SHA2_224 | SHA2_256 -> 4
| SHA2_384 | SHA2_512 -> 5
let k_w (a: sha2_alg) = lseq (word a) (block_word_length a)
let block_t (a: sha2_alg) = lseq uint8 (block_length a)
inline_for_extraction noextract
type ops = {
c0: size_t; c1: size_t; c2: size_t;
c3: size_t; c4: size_t; c5: size_t;
e0: size_t; e1: size_t; e2: size_t;
e3: size_t; e4: size_t; e5: size_t;
}
(* Definition of constants used in word functions *)
inline_for_extraction noextract
let op224_256: ops = {
c0 = 2ul; c1 = 13ul; c2 = 22ul;
c3 = 6ul; c4 = 11ul; c5 = 25ul;
e0 = 7ul; e1 = 18ul; e2 = 3ul;
e3 = 17ul; e4 = 19ul; e5 = 10ul
}
inline_for_extraction noextract
let op384_512: ops = {
c0 = 28ul; c1 = 34ul; c2 = 39ul;
c3 = 14ul; c4 = 18ul; c5 = 41ul;
e0 = 1ul ; e1 = 8ul; e2 = 7ul;
e3 = 19ul; e4 = 61ul; e5 = 6ul
}
inline_for_extraction
let op0: a:sha2_alg -> Tot ops = function
| SHA2_224 -> op224_256
| SHA2_256 -> op224_256
| SHA2_384 -> op384_512
| SHA2_512 -> op384_512
inline_for_extraction
let ( +. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( +. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( +. ) #U64 #SEC
inline_for_extraction
let ( ^. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ^. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ^. ) #U64 #SEC
inline_for_extraction
let ( &. ) (#a:sha2_alg): word a -> word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( &. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( &. ) #U64 #SEC
inline_for_extraction
let ( ~. ) (#a:sha2_alg): word a -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( ~. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( ~. ) #U64 #SEC
inline_for_extraction
let ( >>>. ) (#a:sha2_alg): word a -> rotval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>>. ) #U64 #SEC
inline_for_extraction
let ( >>. ) (#a:sha2_alg): word a -> shiftval (word_t a) -> word a =
match a with
| SHA2_224 | SHA2_256 -> ( >>. ) #U32 #SEC
| SHA2_384 | SHA2_512 -> ( >>. ) #U64 #SEC
(* Definition of the SHA2 word functions *)
inline_for_extraction
val _Ch: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Ch a x y z = (x &. y) ^. (~.x &. z)
inline_for_extraction
val _Maj: a:sha2_alg -> x:(word a) -> y:(word a) -> z:(word a) -> Tot (word a)
let _Maj a x y z = (x &. y) ^. ((x &. z) ^. (y &. z))
inline_for_extraction
val _Sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma0 a x = (x >>>. (op0 a).c0) ^. (x >>>. (op0 a).c1) ^. (x >>>. (op0 a).c2)
inline_for_extraction
val _Sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _Sigma1 a x = (x >>>. (op0 a).c3) ^. (x >>>. (op0 a).c4) ^. (x >>>. (op0 a).c5)
inline_for_extraction
val _sigma0: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma0 a x = (x >>>. (op0 a).e0) ^. (x >>>. (op0 a).e1) ^. (x >>. (op0 a).e2)
inline_for_extraction
val _sigma1: a:sha2_alg -> x:(word a) -> Tot (word a)
let _sigma1 a x = (x >>>. (op0 a).e3) ^. (x >>>. (op0 a).e4) ^. (x >>. (op0 a).e5)
let h0: a:sha2_alg -> Tot (words_state a) = function
| SHA2_224 -> C.h224
| SHA2_256 -> C.h256
| SHA2_384 -> C.h384
| SHA2_512 -> C.h512
let k0: a:sha2_alg -> Tot (m:S.seq (word a) {S.length m = size_k_w a}) = function
| SHA2_224 -> C.k224_256
| SHA2_256 -> C.k224_256
| SHA2_384 -> C.k384_512
| SHA2_512 -> C.k384_512
unfold
let (.[]) = S.index
(* Core shuffling function *)
let shuffle_core_pre (a:sha2_alg) (k_t: word a) (ws_t: word a) (hash:words_state a) : Tot (words_state a) =
(**) assert(7 <= S.length hash);
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
(**) assert(S.length (k0 a) = size_k_w a);
let t1 = h0 +. (_Sigma1 a e0) +. (_Ch a e0 f0 g0) +. k_t +. ws_t in
let t2 = (_Sigma0 a a0) +. (_Maj a a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert_norm (List.Tot.length l = 8);
S.seq_of_list l
(* Scheduling function *)
let ws_next_inner (a:sha2_alg) (i:nat{i < 16}) (ws:k_w a) : k_w a =
let t16 = ws.[i] in
let t15 = ws.[(i+1) % 16] in
let t7 = ws.[(i+9) % 16] in
let t2 = ws.[(i+14) % 16] in
let s1 = _sigma1 a t2 in
let s0 = _sigma0 a t15 in
Seq.upd ws i (s1 +. t7 +. s0 +. t16)
let ws_next (a:sha2_alg) (ws:k_w a) : k_w a =
Lib.LoopCombinators.repeati 16 (ws_next_inner a) ws
val shuffle_inner:
a:sha2_alg
-> ws:k_w a
-> i:nat{i < num_rounds16 a}
-> j:nat{j < 16}
-> hash:words_state a ->
words_state a
let shuffle_inner a ws i j hash =
let k_t = Seq.index (k0 a) (16 * i + j) in
let ws_t = ws.[j] in
shuffle_core_pre a k_t ws_t hash
val shuffle_inner_loop:
a:sha2_alg
-> i:nat{i < num_rounds16 a}
-> ws_st:tuple2 (k_w a) (words_state a) ->
k_w a & words_state a
let shuffle_inner_loop a i (ws, st) =
let st' = Lib.LoopCombinators.repeati 16 (shuffle_inner a ws i) st in
let ws' = if i < num_rounds16 a - 1 then ws_next a ws else ws in
(ws', st')
(* Full shuffling function *)
let shuffle (a:sha2_alg) (ws:k_w a) (hash:words_state a) : Tot (words_state a) =
let (ws, st) = Lib.LoopCombinators.repeati (num_rounds16 a) (shuffle_inner_loop a) (ws, hash) in
st
let init (a:sha2_alg) : words_state a = h0 a
let update (a:sha2_alg) (block:block_t a) (hash:words_state a): Tot (words_state a) =
let block_w = Lib.ByteSequence.uints_from_bytes_be #(word_t a) #SEC #(block_word_length a) block in
let hash_1 = shuffle a block_w hash in
map2 #_ #_ #_ #8 ( +. ) hash_1 hash
let padded_blocks (a:sha2_alg) (len:nat{len <= block_length a}) : n:nat{n <= 2} =
if (len + len_length a + 1 <= block_length a) then 1 else 2 | {
"checked_file": "/",
"dependencies": [
"Spec.SHA2.Constants.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.SHA2.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.SHA2.Constants",
"short_module": "C"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"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": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Hash.Definitions.sha2_alg ->
totlen_seq: Lib.Sequence.lseq Lib.IntTypes.uint8 (Spec.Hash.Definitions.len_length a) ->
fin:
Prims.nat
{ fin == Spec.Hash.Definitions.block_length a \/
fin == 2 * Spec.Hash.Definitions.block_length a } ->
len: Prims.nat{len <= Spec.Hash.Definitions.block_length a} ->
b: Spec.Hash.Definitions.bytes{FStar.Seq.Base.length b = len}
-> Hacl.Spec.SHA2.block_t a * Hacl.Spec.SHA2.block_t a | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.sha2_alg",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.len_length",
"Prims.nat",
"Prims.l_or",
"Prims.eq2",
"Prims.int",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_disEquality",
"Spec.Hash.Definitions.block_length",
"FStar.Mul.op_Star",
"Prims.op_LessThanOrEqual",
"Spec.Hash.Definitions.bytes",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"FStar.Pervasives.Native.Mktuple2",
"Hacl.Spec.SHA2.block_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.l_and",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Prims.op_Multiply",
"Prims.op_Addition",
"Prims.l_Forall",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.Sequence.index",
"Lib.Sequence.sub",
"Prims.op_Subtraction",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.upd",
"Lib.IntTypes.mk_int",
"Prims.pow2",
"Prims.l_imp",
"Lib.Sequence.op_String_Assignment",
"Lib.IntTypes.u8",
"FStar.Seq.Base.create",
"Lib.Sequence.create",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | false | false | let load_last
(a: sha2_alg)
(totlen_seq: lseq uint8 (len_length a))
(fin: nat{fin == block_length a \/ fin == 2 * block_length a})
(len: nat{len <= block_length a})
(b: bytes{S.length b = len})
: (block_t a & block_t a) =
| let last = create (2 * block_length a) (u8 0) in
let last = update_sub last 0 len b in
let last = last.[ len ] <- u8 0x80 in
let last = update_sub last (fin - len_length a) (len_length a) totlen_seq in
let b0 = sub last 0 (block_length a) in
let b1 = sub last (block_length a) (block_length a) in
(b0, b1) | false |
Vale.PPC64LE.Print_s.fst | Vale.PPC64LE.Print_s.print_code | val print_code (c: code) (n: int) (p: printer) : string & int | val print_code (c: code) (n: int) (p: printer) : string & int | let rec print_block (b:codes) (n:int) (p:printer) : string & int =
match b with
| Nil -> ("", n)
| head :: tail ->
let (head_str, n') = print_code head n p in
let (rest, n'') = print_block tail n' p in
(head_str ^ rest, n'')
and print_code (c:code) (n:int) (p:printer) : string & int =
match c with
| Ins ins -> (print_ins ins p ^ "\n", n)
| Block b -> print_block b n p
| IfElse cond true_code false_code ->
let n1 = n in
let n2 = n + 1 in
let cmp = print_cmp (cmp_not cond) n1 p in
let (true_str, n') = print_code true_code (n + 2) p in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = "L" ^ string_of_int n1 ^ ":\n" in
let (false_str, n') = print_code false_code n' p in
let label2 = "L" ^ string_of_int n2 ^ ":\n" in
(cmp ^ true_str ^ branch ^ label1 ^ false_str ^ label2, n')
| While cond body ->
let n1 = n in
let n2 = n + 1 in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = p.align() ^ " 4\nL" ^ string_of_int n1 ^ ":\n" in
let (body_str, n') = print_code body (n + 2) p in
let label2 = p.align() ^ " 4\nL" ^ string_of_int n2 ^ ":\n" in
let cmp = print_cmp cond n1 p in
(branch ^ label1 ^ body_str ^ label2 ^ cmp, n') | {
"file_name": "vale/specs/hardware/Vale.PPC64LE.Print_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 219,
"start_col": 0,
"start_line": 190
} | module Vale.PPC64LE.Print_s
// Trusted code for producing assembly code
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Semantics_s
open FStar.IO
noeq type printer = {
reg_prefix : unit -> string;
vec_prefix : unit -> string;
vsr_prefix : unit -> string;
maddr : string -> string -> string;
const : int -> string;
align : unit -> string;
header : unit -> string;
footer : unit -> string;
proc_name : string -> string;
ret : string -> string;
}
let print_reg (r:reg) (p:printer) =
p.reg_prefix() ^ string_of_int r
let print_vec (v:vec) (vsr:bool) (p:printer) =
if vsr then p.vsr_prefix() ^ "32+" ^ string_of_int v
else p.vec_prefix() ^ string_of_int v
let print_maddr (m:maddr) (p:printer) =
p.maddr (string_of_int m.offset) (print_reg m.address p)
let cmp_not(o:ocmp) : ocmp =
match o with
| OEq o1 o2 -> ONe o1 o2
| ONe o1 o2 -> OEq o1 o2
| OLe o1 o2 -> OGt o1 o2
| OGe o1 o2 -> OLt o1 o2
| OLt o1 o2 -> OGe o1 o2
| OGt o1 o2 -> OLe o1 o2
// Sanity check
let _ = assert (forall o . o == cmp_not (cmp_not o))
let print_first_cmp_opr (o:cmp_opr) (p:printer) =
match o with
| CReg r -> print_reg r p
| _ -> "!!! INVALID first compare operand !!! Expected general purpose register."
let print_ins (ins:ins) (p:printer) =
let print_pair (o1 o2:string) =
o1 ^ ", " ^ o2
in
let print_triple (o1 o2 o3:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3
in
let print_quadruple (o1 o2 o3 o4:string) =
o1 ^ ", " ^ o2 ^ ", " ^ o3 ^ ", " ^ o4
in
let print_reg_pair (dst src:reg) =
print_pair (print_reg dst p) (print_reg src p)
in
let print_reg_mem (o1:reg) (o2:maddr) =
print_pair (print_reg o1 p) (print_maddr o2 p)
in
let print_reg_triple (dst src1 src2:reg) =
print_triple (print_reg dst p) (print_reg src1 p) (print_reg src2 p)
in
let print_reg_imm (dst:reg) (src:int) =
print_pair (print_reg dst p) (p.const src)
in
let print_reg_pair_imm (dst src1:reg) (src2:int) =
print_triple (print_reg dst p) (print_reg src1 p) (p.const src2)
in
let print_reg_vec (dst:reg) (src:vec) (vsr:bool) =
print_pair (print_reg dst p) (print_vec src vsr p)
in
let print_vec_reg (dst:vec) (src:reg) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_reg src p)
in
let print_vec_reg_pair (dst:vec) (src1 src2:reg) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_reg src1 p) (print_reg src2 p)
in
let print_vec_pair (dst src:vec) (vsr:bool) =
print_pair (print_vec dst vsr p) (print_vec src vsr p)
in
let print_vec_triple (dst src1 src2:vec) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p)
in
let print_vec_quadruple (dst src1 src2 src3:vec) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (print_vec src3 vsr p)
in
let print_vec_imm (dst:vec) (src:int) (vsr:bool) =
print_pair (print_vec dst vsr p) (p.const src)
in
let print_vec_pair_imm (dst src:vec) (imm:int) (vsr:bool) =
print_triple (print_vec dst vsr p) (print_vec src vsr p) (p.const imm)
in
let print_vec_triple_imm (dst src1 src2:vec) (count:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src1 vsr p) (print_vec src2 vsr p) (p.const count)
in
let print_vec_mem (o1:vec) (o2:maddr) (vsr:bool) =
print_pair (print_vec o1 vsr p) (print_maddr o2 p)
in
let print_vec_pair_imm_pair (dst src:vec) (s0 s1:int) (vsr:bool) =
print_quadruple (print_vec dst vsr p) (print_vec src vsr p) (p.const s0) (p.const s1)
in
match ins with
| Move dst src -> " mr " ^ print_reg_pair dst src
| Load64 dst base offset -> " ld " ^ print_reg_mem dst ({ address = base; offset = offset })
| Store64 src base offset -> " std " ^ print_reg_mem src ({ address = base; offset = offset })
| LoadImm64 dst src -> " li " ^ print_reg_imm dst src
| LoadImmShl64 dst src -> " lis " ^ print_reg_imm dst src
| AddLa dst src1 src2 -> " la " ^ print_reg_mem dst ({ address = src1; offset = src2 })
| Add dst src1 src2 -> " add " ^ print_reg_triple dst src1 src2
| AddImm dst src1 src2 -> " addi " ^ print_reg_pair_imm dst src1 src2
| AddCarry dst src1 src2 -> " addc " ^ print_reg_triple dst src1 src2
| AddExtended dst src1 src2 -> " adde " ^ print_reg_triple dst src1 src2
| AddExtendedOV dst src1 src2 -> " addex " ^ print_reg_triple dst src1 src2
| Sub dst src1 src2 -> " sub " ^ print_reg_triple dst src1 src2
| SubImm dst src1 src2 -> " subi " ^ print_reg_pair_imm dst src1 src2
| MulLow64 dst src1 src2 -> " mulld " ^ print_reg_triple dst src1 src2
| MulHigh64U dst src1 src2 -> " mulhdu " ^ print_reg_triple dst src1 src2
| Xor dst src1 src2 -> " xor " ^ print_reg_triple dst src1 src2
| And dst src1 src2 -> " and " ^ print_reg_triple dst src1 src2
| Sr64Imm dst src1 src2 -> " srdi " ^ print_reg_pair_imm dst src1 src2
| Sl64Imm dst src1 src2 -> " sldi " ^ print_reg_pair_imm dst src1 src2
| Sr64 dst src1 src2 -> " srd " ^ print_reg_triple dst src1 src2
| Sl64 dst src1 src2 -> " sld " ^ print_reg_triple dst src1 src2
| Vmr dst src -> " vmr " ^ print_vec_pair dst src false
| Mfvsrd dst src -> " mfvsrd " ^ print_reg_vec dst src true
| Mfvsrld dst src -> " mfvsrld " ^ print_reg_vec dst src true
| Mtvsrdd dst src1 src2 -> " mtvsrdd " ^ print_vec_reg_pair dst src1 src2 true
| Mtvsrws dst src -> " mtvsrws " ^ print_vec_reg dst src true
| Vadduwm dst src1 src2 -> " vadduwm " ^ print_vec_triple dst src1 src2 false
| Vxor dst src1 src2 -> " vxor " ^ print_vec_triple dst src1 src2 false
| Vand dst src1 src2 -> " vand " ^ print_vec_triple dst src1 src2 false
| Vslw dst src1 src2 -> " vslw " ^ print_vec_triple dst src1 src2 false
| Vsrw dst src1 src2 -> " vsrw " ^ print_vec_triple dst src1 src2 false
| Vsl dst src1 src2 -> " vsl " ^ print_vec_triple dst src1 src2 false
| Vcmpequw dst src1 src2 -> " vcmpequw " ^ print_vec_triple dst src1 src2 false
| Vsldoi dst src1 src2 count -> " vsldoi " ^ print_vec_triple_imm dst src1 src2 count false
| Vmrghw dst src1 src2 -> " vmrghw " ^ print_vec_triple dst src1 src2 false
| Xxmrghd dst src1 src2 -> " xxmrghd " ^ print_vec_triple dst src1 src2 true
| Vsel dst src1 src2 sel -> " vsel " ^ print_vec_quadruple dst src1 src2 sel false
| Vspltw dst src uim -> " vspltw " ^ print_vec_pair_imm dst src uim false
| Vspltisw dst src -> " vspltisw " ^ print_vec_imm dst src false
| Vspltisb dst src -> " vspltisb " ^ print_vec_imm dst src false
| Load128 dst base offset -> " lvx " ^ print_vec_reg_pair dst offset base false
| Store128 src base offset -> " stvx " ^ print_vec_reg_pair src offset base false
| Load128Word4 dst base -> " lxvw4x " ^ print_vec_reg_pair dst 0 base true
| Load128Word4Index dst base offset -> " lxvw4x " ^ print_vec_reg_pair dst offset base true
| Store128Word4 src base -> " stxvw4x " ^ print_vec_reg_pair src 0 base true
| Store128Word4Index src base offset -> " stxvw4x " ^ print_vec_reg_pair src offset base true
| Load128Byte16 dst base -> " lxvb16x " ^ print_vec_reg_pair dst 0 base true
| Load128Byte16Index dst base offset -> " lxvb16x " ^ print_vec_reg_pair dst offset base true
| Store128Byte16 src base -> " stxvb16x " ^ print_vec_reg_pair src 0 base true
| Store128Byte16Index src base offset -> " stxvb16x " ^ print_vec_reg_pair src offset base true
| Vshasigmaw0 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 0 false
| Vshasigmaw1 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 0 15 false
| Vshasigmaw2 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 0 false
| Vshasigmaw3 dst src -> " vshasigmaw " ^ print_vec_pair_imm_pair dst src 1 15 false
| Vsbox dst src -> " vsbox " ^ print_vec_pair dst src false
| RotWord dst src1 src2 -> " vrlw " ^ print_vec_triple dst src1 src2 false
| Vcipher dst src1 src2 -> " vcipher " ^ print_vec_triple dst src1 src2 false
| Vcipherlast dst src1 src2 -> " vcipherlast " ^ print_vec_triple dst src1 src2 false
| Vncipher dst src1 src2 -> " vncipher " ^ print_vec_triple dst src1 src2 false
| Vncipherlast dst src1 src2 -> " vncipherlast " ^ print_vec_triple dst src1 src2 false
| Vpmsumd dst src1 src2 -> " vpmsumd " ^ print_vec_triple dst src1 src2 false
| Alloc n -> " subi " ^ print_reg_pair_imm 1 1 n
| Dealloc n -> " addi " ^ print_reg_pair_imm 1 1 n
| StoreStack128 src t offset -> " stxv " ^ print_vec_mem src ({ address = 1; offset = offset }) true
| LoadStack128 dst t offset -> " lxv " ^ print_vec_mem dst ({ address = 1; offset = offset }) true
| StoreStack64 src t offset -> " std " ^ print_reg_mem src ({ address = 1; offset = offset })
| LoadStack64 dst t offset -> " ld " ^ print_reg_mem dst ({ address = 1; offset = offset })
| Ghost _ -> ""
let print_cmp (c:ocmp) (counter:int) (p:printer) : string =
let print_cmp_ops (o1:cmp_opr) (o2:cmp_opr) : string =
match o2 with
| CReg r -> " cmpld " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (print_reg r p) ^ "\n"
| CImm n -> " cmpldi " ^ (print_first_cmp_opr o1 p) ^ ", " ^ (string_of_int n) ^ "\n"
in
match c with
| OEq o1 o2 -> print_cmp_ops o1 o2 ^ " beq " ^ "L" ^ string_of_int counter ^ "\n"
| ONe o1 o2 -> print_cmp_ops o1 o2 ^ " bne "^ "L" ^ string_of_int counter ^ "\n"
| OLe o1 o2 -> print_cmp_ops o1 o2 ^ " ble "^ "L" ^ string_of_int counter ^ "\n"
| OGe o1 o2 -> print_cmp_ops o1 o2 ^ " bge "^ "L" ^ string_of_int counter ^ "\n"
| OLt o1 o2 -> print_cmp_ops o1 o2 ^ " blt " ^ "L" ^ string_of_int counter ^ "\n"
| OGt o1 o2 -> print_cmp_ops o1 o2 ^ " bgt " ^ "L" ^ string_of_int counter ^ "\n" | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.IO.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Print_s.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.IO",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Vale.PPC64LE.Semantics_s.code -> n: Prims.int -> p: Vale.PPC64LE.Print_s.printer
-> Prims.string * Prims.int | Prims.Tot | [
"total"
] | [
"print_block",
"print_code"
] | [
"Vale.PPC64LE.Semantics_s.code",
"Prims.int",
"Vale.PPC64LE.Print_s.printer",
"Vale.PPC64LE.Semantics_s.ins",
"FStar.Pervasives.Native.Mktuple2",
"Prims.string",
"Prims.op_Hat",
"Vale.PPC64LE.Print_s.print_ins",
"Prims.list",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Semantics_s.ocmp",
"Vale.PPC64LE.Print_s.print_block",
"Prims.string_of_int",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Print_s.print_code",
"Prims.op_Addition",
"Vale.PPC64LE.Print_s.print_cmp",
"Vale.PPC64LE.Print_s.cmp_not",
"Vale.PPC64LE.Print_s.__proj__Mkprinter__item__align"
] | [
"mutual recursion"
] | false | false | false | true | false | let rec print_code (c: code) (n: int) (p: printer) : string & int =
| match c with
| Ins ins -> (print_ins ins p ^ "\n", n)
| Block b -> print_block b n p
| IfElse cond true_code false_code ->
let n1 = n in
let n2 = n + 1 in
let cmp = print_cmp (cmp_not cond) n1 p in
let true_str, n' = print_code true_code (n + 2) p in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = "L" ^ string_of_int n1 ^ ":\n" in
let false_str, n' = print_code false_code n' p in
let label2 = "L" ^ string_of_int n2 ^ ":\n" in
(cmp ^ true_str ^ branch ^ label1 ^ false_str ^ label2, n')
| While cond body ->
let n1 = n in
let n2 = n + 1 in
let branch = " b L" ^ string_of_int n2 ^ "\n" in
let label1 = p.align () ^ " 4\nL" ^ string_of_int n1 ^ ":\n" in
let body_str, n' = print_code body (n + 2) p in
let label2 = p.align () ^ " 4\nL" ^ string_of_int n2 ^ ":\n" in
let cmp = print_cmp cond n1 p in
(branch ^ label1 ^ body_str ^ label2 ^ cmp, n') | false |
InterpreterTarget.fsti | InterpreterTarget.expr | val expr : Type0 | let expr = T.expr | {
"file_name": "src/3d/InterpreterTarget.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 17,
"end_line": 22,
"start_col": 0,
"start_line": 22
} | (*
Copyright 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 InterpreterTarget
(* The abstract syntax for the code produced by 3d, targeting prelude/Interpreter.fst *)
open FStar.All
module A = Ast
module T = Target | {
"checked_file": "/",
"dependencies": [
"Target.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "InterpreterTarget.fsti"
} | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": 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"
] | [] | [
"Target.expr"
] | [] | false | false | false | true | true | let expr =
| T.expr | false |
|
InterpreterTarget.fsti | InterpreterTarget.lam | val lam : a: Type -> Type | let lam a = A.ident & a | {
"file_name": "src/3d/InterpreterTarget.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 23,
"end_line": 24,
"start_col": 0,
"start_line": 24
} | (*
Copyright 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 InterpreterTarget
(* The abstract syntax for the code produced by 3d, targeting prelude/Interpreter.fst *)
open FStar.All
module A = Ast
module T = Target
open Binding
let expr = T.expr | {
"checked_file": "/",
"dependencies": [
"Target.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "InterpreterTarget.fsti"
} | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> Type | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.tuple2",
"Ast.ident"
] | [] | false | false | false | true | true | let lam a =
| A.ident & a | false |
|
InterpreterTarget.fsti | InterpreterTarget.readable_itype | val readable_itype : Type0 | let readable_itype = (i: itype { allow_reader_of_itype i == true }) | {
"file_name": "src/3d/InterpreterTarget.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 67,
"end_line": 45,
"start_col": 0,
"start_line": 45
} | (*
Copyright 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 InterpreterTarget
(* The abstract syntax for the code produced by 3d, targeting prelude/Interpreter.fst *)
open FStar.All
module A = Ast
module T = Target
open Binding
let expr = T.expr
let action = T.action
let lam a = A.ident & a
type itype =
| UInt8
| UInt16
| UInt32
| UInt64
| UInt8BE
| UInt16BE
| UInt32BE
| UInt64BE
| Unit
| AllBytes
| AllZeros
let allow_reader_of_itype (i:itype)
: bool
= match i with
| AllBytes
| AllZeros -> false
| _ -> true | {
"checked_file": "/",
"dependencies": [
"Target.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "InterpreterTarget.fsti"
} | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": 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"
] | [] | [
"InterpreterTarget.itype",
"Prims.eq2",
"Prims.bool",
"InterpreterTarget.allow_reader_of_itype"
] | [] | false | false | false | true | true | let readable_itype =
| (i: itype{allow_reader_of_itype i == true}) | false |
|
InterpreterTarget.fsti | InterpreterTarget.action | val action : Type0 | let action = T.action | {
"file_name": "src/3d/InterpreterTarget.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 21,
"end_line": 23,
"start_col": 0,
"start_line": 23
} | (*
Copyright 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 InterpreterTarget
(* The abstract syntax for the code produced by 3d, targeting prelude/Interpreter.fst *)
open FStar.All
module A = Ast
module T = Target
open Binding | {
"checked_file": "/",
"dependencies": [
"Target.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "InterpreterTarget.fsti"
} | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": 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"
] | [] | [
"Target.action"
] | [] | false | false | false | true | true | let action =
| T.action | false |
|
InterpreterTarget.fsti | InterpreterTarget.readable_dtyp | val readable_dtyp : Type0 | let readable_dtyp = (d: dtyp { allow_reader_of_dtyp d == true }) | {
"file_name": "src/3d/InterpreterTarget.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 64,
"end_line": 63,
"start_col": 0,
"start_line": 63
} | (*
Copyright 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 InterpreterTarget
(* The abstract syntax for the code produced by 3d, targeting prelude/Interpreter.fst *)
open FStar.All
module A = Ast
module T = Target
open Binding
let expr = T.expr
let action = T.action
let lam a = A.ident & a
type itype =
| UInt8
| UInt16
| UInt32
| UInt64
| UInt8BE
| UInt16BE
| UInt32BE
| UInt64BE
| Unit
| AllBytes
| AllZeros
let allow_reader_of_itype (i:itype)
: bool
= match i with
| AllBytes
| AllZeros -> false
| _ -> true
let readable_itype = (i: itype { allow_reader_of_itype i == true })
noeq
type dtyp : Type =
| DT_IType:
i:itype -> dtyp
| DT_App:
readable: bool ->
hd:A.ident ->
args:list expr ->
dtyp
let allow_reader_of_dtyp (d: dtyp) : Tot bool =
match d with
| DT_IType i -> allow_reader_of_itype i
| DT_App readable _ _ -> readable | {
"checked_file": "/",
"dependencies": [
"Target.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "InterpreterTarget.fsti"
} | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": 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"
] | [] | [
"InterpreterTarget.dtyp",
"Prims.eq2",
"Prims.bool",
"InterpreterTarget.allow_reader_of_dtyp"
] | [] | false | false | false | true | true | let readable_dtyp =
| (d: dtyp{allow_reader_of_dtyp d == true}) | false |
|
InterpreterTarget.fsti | InterpreterTarget.allow_reader_of_itype | val allow_reader_of_itype (i: itype) : bool | val allow_reader_of_itype (i: itype) : bool | let allow_reader_of_itype (i:itype)
: bool
= match i with
| AllBytes
| AllZeros -> false
| _ -> true | {
"file_name": "src/3d/InterpreterTarget.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 15,
"end_line": 43,
"start_col": 0,
"start_line": 38
} | (*
Copyright 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 InterpreterTarget
(* The abstract syntax for the code produced by 3d, targeting prelude/Interpreter.fst *)
open FStar.All
module A = Ast
module T = Target
open Binding
let expr = T.expr
let action = T.action
let lam a = A.ident & a
type itype =
| UInt8
| UInt16
| UInt32
| UInt64
| UInt8BE
| UInt16BE
| UInt32BE
| UInt64BE
| Unit
| AllBytes
| AllZeros | {
"checked_file": "/",
"dependencies": [
"Target.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "InterpreterTarget.fsti"
} | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": 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 | i: InterpreterTarget.itype -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"InterpreterTarget.itype",
"Prims.bool"
] | [] | false | false | false | true | false | let allow_reader_of_itype (i: itype) : bool =
| match i with
| AllBytes | AllZeros -> false
| _ -> true | false |
InterpreterTarget.fsti | InterpreterTarget.non_empty_string | val non_empty_string : Type0 | let non_empty_string = s:string { s <> "" } | {
"file_name": "src/3d/InterpreterTarget.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 43,
"end_line": 65,
"start_col": 0,
"start_line": 65
} | (*
Copyright 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 InterpreterTarget
(* The abstract syntax for the code produced by 3d, targeting prelude/Interpreter.fst *)
open FStar.All
module A = Ast
module T = Target
open Binding
let expr = T.expr
let action = T.action
let lam a = A.ident & a
type itype =
| UInt8
| UInt16
| UInt32
| UInt64
| UInt8BE
| UInt16BE
| UInt32BE
| UInt64BE
| Unit
| AllBytes
| AllZeros
let allow_reader_of_itype (i:itype)
: bool
= match i with
| AllBytes
| AllZeros -> false
| _ -> true
let readable_itype = (i: itype { allow_reader_of_itype i == true })
noeq
type dtyp : Type =
| DT_IType:
i:itype -> dtyp
| DT_App:
readable: bool ->
hd:A.ident ->
args:list expr ->
dtyp
let allow_reader_of_dtyp (d: dtyp) : Tot bool =
match d with
| DT_IType i -> allow_reader_of_itype i
| DT_App readable _ _ -> readable
let readable_dtyp = (d: dtyp { allow_reader_of_dtyp d == true }) | {
"checked_file": "/",
"dependencies": [
"Target.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "InterpreterTarget.fsti"
} | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": 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"
] | [] | [
"Prims.string",
"Prims.b2t",
"Prims.op_disEquality"
] | [] | false | false | false | true | true | let non_empty_string =
| s: string{s <> ""} | false |
|
InterpreterTarget.fsti | InterpreterTarget.decl | val decl:Type0 | val decl:Type0 | let decl : Type0 = either not_type_decl type_decl | {
"file_name": "src/3d/InterpreterTarget.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 49,
"end_line": 197,
"start_col": 0,
"start_line": 197
} | (*
Copyright 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 InterpreterTarget
(* The abstract syntax for the code produced by 3d, targeting prelude/Interpreter.fst *)
open FStar.All
module A = Ast
module T = Target
open Binding
let expr = T.expr
let action = T.action
let lam a = A.ident & a
type itype =
| UInt8
| UInt16
| UInt32
| UInt64
| UInt8BE
| UInt16BE
| UInt32BE
| UInt64BE
| Unit
| AllBytes
| AllZeros
let allow_reader_of_itype (i:itype)
: bool
= match i with
| AllBytes
| AllZeros -> false
| _ -> true
let readable_itype = (i: itype { allow_reader_of_itype i == true })
noeq
type dtyp : Type =
| DT_IType:
i:itype -> dtyp
| DT_App:
readable: bool ->
hd:A.ident ->
args:list expr ->
dtyp
let allow_reader_of_dtyp (d: dtyp) : Tot bool =
match d with
| DT_IType i -> allow_reader_of_itype i
| DT_App readable _ _ -> readable
let readable_dtyp = (d: dtyp { allow_reader_of_dtyp d == true })
let non_empty_string = s:string { s <> "" }
let nes (s:string)
: non_empty_string
= if s = "" then "missing" else s
noeq
type typ : Type =
| T_false:
fn:non_empty_string ->
typ
| T_denoted:
fn:non_empty_string ->
d:dtyp ->
typ
| T_pair:
fn:non_empty_string ->
t1:typ ->
t2:typ ->
typ
| T_dep_pair:
fn:non_empty_string ->
t1:readable_dtyp ->
t2:lam typ ->
typ
| T_refine:
fn:non_empty_string ->
base:readable_dtyp ->
refinement:lam expr ->
typ
| T_refine_with_action:
fn:non_empty_string ->
base:readable_dtyp ->
refinement:lam expr ->
a:lam action ->
typ
| T_dep_pair_with_refinement:
fn:non_empty_string ->
base:readable_dtyp ->
refinement:lam expr ->
k:lam typ ->
typ
| T_dep_pair_with_action:
fn:non_empty_string ->
base:readable_dtyp ->
k:lam typ ->
a:lam action ->
typ
| T_dep_pair_with_refinement_and_action:
fn:non_empty_string ->
base:readable_dtyp ->
refinement:lam expr ->
k:lam typ ->
a:lam action ->
typ
| T_if_else:
b:expr ->
t1:typ ->
t2:typ ->
typ
| T_with_action:
fn:non_empty_string ->
base:typ ->
act:action ->
typ
| T_with_dep_action:
fn:non_empty_string ->
head:readable_dtyp ->
act:lam action ->
typ
| T_with_comment:
fn:non_empty_string ->
t:typ ->
c:string ->
typ
| T_nlist:
fn:non_empty_string ->
n:expr ->
t:typ ->
typ
| T_at_most:
fn:non_empty_string ->
n:expr ->
t:typ ->
typ
| T_exact:
fn:non_empty_string ->
n:expr ->
t:typ ->
typ
| T_string:
fn:non_empty_string ->
element_type:readable_dtyp ->
terminator:expr ->
typ
| T_probe_then_validate:
fn:non_empty_string ->
t:dtyp ->
probe:A.ident ->
len:expr ->
dest:A.ident ->
typ
val typ_indexes : Type0
noeq
type type_decl = {
name : T.typedef_name;
typ : typ;
kind : T.parser_kind;
typ_indexes : typ_indexes;
allow_reading: bool;
attrs : T.decl_attributes;
enum_typ: option (t:T.typ {T.T_refine? t })
} | {
"checked_file": "/",
"dependencies": [
"Target.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "InterpreterTarget.fsti"
} | [
{
"abbrev": true,
"full_module": "Hashtable",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": 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.either",
"InterpreterTarget.not_type_decl",
"InterpreterTarget.type_decl"
] | [] | false | false | false | true | true | let decl:Type0 =
| either not_type_decl type_decl | false |
InterpreterTarget.fsti | InterpreterTarget.not_type_decl | val not_type_decl : Type0 | let not_type_decl = (d: T.decl { ~ (T.Type_decl? (fst d)) }) | {
"file_name": "src/3d/InterpreterTarget.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 60,
"end_line": 196,
"start_col": 0,
"start_line": 196
} | (*
Copyright 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 InterpreterTarget
(* The abstract syntax for the code produced by 3d, targeting prelude/Interpreter.fst *)
open FStar.All
module A = Ast
module T = Target
open Binding
let expr = T.expr
let action = T.action
let lam a = A.ident & a
type itype =
| UInt8
| UInt16
| UInt32
| UInt64
| UInt8BE
| UInt16BE
| UInt32BE
| UInt64BE
| Unit
| AllBytes
| AllZeros
let allow_reader_of_itype (i:itype)
: bool
= match i with
| AllBytes
| AllZeros -> false
| _ -> true
let readable_itype = (i: itype { allow_reader_of_itype i == true })
noeq
type dtyp : Type =
| DT_IType:
i:itype -> dtyp
| DT_App:
readable: bool ->
hd:A.ident ->
args:list expr ->
dtyp
let allow_reader_of_dtyp (d: dtyp) : Tot bool =
match d with
| DT_IType i -> allow_reader_of_itype i
| DT_App readable _ _ -> readable
let readable_dtyp = (d: dtyp { allow_reader_of_dtyp d == true })
let non_empty_string = s:string { s <> "" }
let nes (s:string)
: non_empty_string
= if s = "" then "missing" else s
noeq
type typ : Type =
| T_false:
fn:non_empty_string ->
typ
| T_denoted:
fn:non_empty_string ->
d:dtyp ->
typ
| T_pair:
fn:non_empty_string ->
t1:typ ->
t2:typ ->
typ
| T_dep_pair:
fn:non_empty_string ->
t1:readable_dtyp ->
t2:lam typ ->
typ
| T_refine:
fn:non_empty_string ->
base:readable_dtyp ->
refinement:lam expr ->
typ
| T_refine_with_action:
fn:non_empty_string ->
base:readable_dtyp ->
refinement:lam expr ->
a:lam action ->
typ
| T_dep_pair_with_refinement:
fn:non_empty_string ->
base:readable_dtyp ->
refinement:lam expr ->
k:lam typ ->
typ
| T_dep_pair_with_action:
fn:non_empty_string ->
base:readable_dtyp ->
k:lam typ ->
a:lam action ->
typ
| T_dep_pair_with_refinement_and_action:
fn:non_empty_string ->
base:readable_dtyp ->
refinement:lam expr ->
k:lam typ ->
a:lam action ->
typ
| T_if_else:
b:expr ->
t1:typ ->
t2:typ ->
typ
| T_with_action:
fn:non_empty_string ->
base:typ ->
act:action ->
typ
| T_with_dep_action:
fn:non_empty_string ->
head:readable_dtyp ->
act:lam action ->
typ
| T_with_comment:
fn:non_empty_string ->
t:typ ->
c:string ->
typ
| T_nlist:
fn:non_empty_string ->
n:expr ->
t:typ ->
typ
| T_at_most:
fn:non_empty_string ->
n:expr ->
t:typ ->
typ
| T_exact:
fn:non_empty_string ->
n:expr ->
t:typ ->
typ
| T_string:
fn:non_empty_string ->
element_type:readable_dtyp ->
terminator:expr ->
typ
| T_probe_then_validate:
fn:non_empty_string ->
t:dtyp ->
probe:A.ident ->
len:expr ->
dest:A.ident ->
typ
val typ_indexes : Type0
noeq
type type_decl = {
name : T.typedef_name;
typ : typ;
kind : T.parser_kind;
typ_indexes : typ_indexes;
allow_reading: bool;
attrs : T.decl_attributes;
enum_typ: option (t:T.typ {T.T_refine? t }) | {
"checked_file": "/",
"dependencies": [
"Target.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "InterpreterTarget.fsti"
} | [
{
"abbrev": true,
"full_module": "Hashtable",
"short_module": "H"
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": 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"
] | [] | [
"Target.decl",
"Prims.l_not",
"Prims.b2t",
"Target.uu___is_Type_decl",
"FStar.Pervasives.Native.fst",
"Target.decl'",
"Target.decl_attributes"
] | [] | false | false | false | true | true | let not_type_decl =
| (d: T.decl{~(T.Type_decl? (fst d))}) | false |
|
Vale.AES.AES256_helpers_BE.fst | Vale.AES.AES256_helpers_BE.lemma_reveal_expand_key_256 | val lemma_reveal_expand_key_256 (key: aes_key_word AES_256) (round: nat)
: Lemma
(expand_key_256 key round ==
(if round = 0
then Mkfour key.[ 3 ] key.[ 2 ] key.[ 1 ] key.[ 0 ]
else
if round = 1
then Mkfour key.[ 7 ] key.[ 6 ] key.[ 5 ] key.[ 4 ]
else round_key_256 (expand_key_256 key (round - 2)) (expand_key_256 key (round - 1)) round
)) | val lemma_reveal_expand_key_256 (key: aes_key_word AES_256) (round: nat)
: Lemma
(expand_key_256 key round ==
(if round = 0
then Mkfour key.[ 3 ] key.[ 2 ] key.[ 1 ] key.[ 0 ]
else
if round = 1
then Mkfour key.[ 7 ] key.[ 6 ] key.[ 5 ] key.[ 4 ]
else round_key_256 (expand_key_256 key (round - 2)) (expand_key_256 key (round - 1)) round
)) | let lemma_reveal_expand_key_256 (key:aes_key_word AES_256) (round:nat) : Lemma
(expand_key_256 key round == (
if round = 0 then Mkfour key.[3] key.[2] key.[1] key.[0]
else if round = 1 then Mkfour key.[7] key.[6] key.[5] key.[4]
else round_key_256 (expand_key_256 key (round - 2)) (expand_key_256 key (round - 1)) round
))
=
expand_key_256_reveal () | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers_BE.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 10,
"start_col": 0,
"start_line": 3
} | module Vale.AES.AES256_helpers_BE | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.AES.AES256_helpers_BE.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": 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 | key: Vale.AES.AES_BE_s.aes_key_word Vale.AES.AES_common_s.AES_256 -> round: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
Vale.AES.AES256_helpers_BE.expand_key_256 key round ==
(match round = 0 with
| true -> Vale.Def.Words_s.Mkfour key.[ 3 ] key.[ 2 ] key.[ 1 ] key.[ 0 ]
| _ ->
(match round = 1 with
| true -> Vale.Def.Words_s.Mkfour key.[ 7 ] key.[ 6 ] key.[ 5 ] key.[ 4 ]
| _ ->
Vale.AES.AES256_helpers_BE.round_key_256 (Vale.AES.AES256_helpers_BE.expand_key_256 key
(round - 2))
(Vale.AES.AES256_helpers_BE.expand_key_256 key (round - 1))
round)
<:
Vale.Def.Words_s.four Vale.Def.Types_s.nat32)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.AES.AES_BE_s.aes_key_word",
"Vale.AES.AES_common_s.AES_256",
"Prims.nat",
"Vale.AES.AES256_helpers_BE.expand_key_256_reveal",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Vale.Def.Words_s.four",
"Vale.Def.Types_s.nat32",
"Vale.AES.AES256_helpers_BE.expand_key_256",
"Prims.op_Equality",
"Prims.int",
"Vale.Def.Words_s.Mkfour",
"Vale.AES.AES256_helpers_BE.op_String_Access",
"Prims.bool",
"Vale.AES.AES256_helpers_BE.round_key_256",
"Prims.op_Subtraction",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_reveal_expand_key_256 (key: aes_key_word AES_256) (round: nat)
: Lemma
(expand_key_256 key round ==
(if round = 0
then Mkfour key.[ 3 ] key.[ 2 ] key.[ 1 ] key.[ 0 ]
else
if round = 1
then Mkfour key.[ 7 ] key.[ 6 ] key.[ 5 ] key.[ 4 ]
else round_key_256 (expand_key_256 key (round - 2)) (expand_key_256 key (round - 1)) round
)) =
| expand_key_256_reveal () | false |
FStar.Int8.fsti | FStar.Int8.n | val n : Prims.int | let n = 8 | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 16,
"end_line": 20,
"start_col": 7,
"start_line": 20
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let n =
| 8 | false |
|
FStar.Int8.fsti | FStar.Int8.eq | val eq (a b: t) : Tot bool | val eq (a b: t) : Tot bool | let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 114,
"start_col": 0,
"start_line": 114
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> b: FStar.Int8.t -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.Int8.t",
"FStar.Int.eq",
"FStar.Int8.n",
"FStar.Int8.v",
"Prims.bool"
] | [] | false | false | false | true | false | let eq (a b: t) : Tot bool =
| eq #n (v a) (v b) | false |
FStar.Int8.fsti | FStar.Int8.gt | val gt (a b: t) : Tot bool | val gt (a b: t) : Tot bool | let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 115,
"start_col": 0,
"start_line": 115
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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 *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> b: FStar.Int8.t -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.Int8.t",
"FStar.Int.gt",
"FStar.Int8.n",
"FStar.Int8.v",
"Prims.bool"
] | [] | false | false | false | true | false | let gt (a b: t) : Tot bool =
| gt #n (v a) (v b) | false |
FStar.Int8.fsti | FStar.Int8.gte | val gte (a b: t) : Tot bool | val gte (a b: t) : Tot bool | let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 51,
"end_line": 116,
"start_col": 0,
"start_line": 116
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> b: FStar.Int8.t -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.Int8.t",
"FStar.Int.gte",
"FStar.Int8.n",
"FStar.Int8.v",
"Prims.bool"
] | [] | false | false | false | true | false | let gte (a b: t) : Tot bool =
| gte #n (v a) (v b) | false |
Vale.AES.AES256_helpers_BE.fst | Vale.AES.AES256_helpers_BE.lemma_expand_append | val lemma_expand_append (key: aes_key_word AES_256) (size1 size2: nat)
: Lemma (requires size1 <= size2 /\ size2 <= 60)
(ensures equal (expand_key AES_256 key size1) (slice (expand_key AES_256 key size2) 0 size1))
(decreases size2) | val lemma_expand_append (key: aes_key_word AES_256) (size1 size2: nat)
: Lemma (requires size1 <= size2 /\ size2 <= 60)
(ensures equal (expand_key AES_256 key size1) (slice (expand_key AES_256 key size2) 0 size1))
(decreases size2) | let rec lemma_expand_append (key:aes_key_word AES_256) (size1:nat) (size2:nat) : Lemma
(requires size1 <= size2 /\ size2 <= 60)
(ensures equal (expand_key AES_256 key size1) (slice (expand_key AES_256 key size2) 0 size1))
(decreases size2)
=
expand_key_reveal ();
if size1 < size2 then lemma_expand_append key size1 (size2 - 1) | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers_BE.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 57,
"start_col": 0,
"start_line": 51
} | module Vale.AES.AES256_helpers_BE
let lemma_reveal_expand_key_256 (key:aes_key_word AES_256) (round:nat) : Lemma
(expand_key_256 key round == (
if round = 0 then Mkfour key.[3] key.[2] key.[1] key.[0]
else if round = 1 then Mkfour key.[7] key.[6] key.[5] key.[4]
else round_key_256 (expand_key_256 key (round - 2)) (expand_key_256 key (round - 1)) round
))
=
expand_key_256_reveal ()
#reset-options "--fuel 8 --ifuel 0"
let lemma_expand_key_256_0 (key:aes_key_word AES_256) : Lemma
(equal key (expand_key AES_256 key 8))
=
expand_key_reveal ()
open FStar.Mul
#reset-options "--fuel 1 --ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'"
let lemma_expand_key_256_i (key:aes_key_word AES_256) (i:nat) : Lemma
(requires
1 < i /\ i < 15
)
(ensures (
let m = 4 * (i - 2) in
let n = 4 * i in
let v = expand_key AES_256 key n in // Current
let w = expand_key AES_256 key (n + 4) in // Next 4 words
let prev0 = Mkfour v.[m + 3] v.[m + 2] v.[m + 1] v.[m + 0] in // Penultimate 4 words in Current
let prev1 = Mkfour v.[m + 7] v.[m + 6] v.[m + 5] v.[m + 4] in // Ultimate 4 words in Current
round_key_256 prev0 prev1 i == Mkfour w.[n + 3] w.[n + 2] w.[n + 1] w.[n + 0] // NextQuad == Next 4 words
))
=
expand_key_reveal ();
let n = 4 * i in
// unfold expand_key 8 times (could use fuel, but that unfolds everything):
let _ = expand_key AES_256 key (n + 1) in
let _ = expand_key AES_256 key (n + 2) in
let _ = expand_key AES_256 key (n + 3) in
let _ = expand_key AES_256 key (n + 4) in
if i < 14 then (
let _ = expand_key AES_256 key (n + 5) in
let _ = expand_key AES_256 key (n + 6) in
let _ = expand_key AES_256 key (n + 7) in
()
) else ();
()
#reset-options | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.AES.AES256_helpers_BE.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": 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 |
key: Vale.AES.AES_BE_s.aes_key_word Vale.AES.AES_common_s.AES_256 ->
size1: Prims.nat ->
size2: Prims.nat
-> FStar.Pervasives.Lemma (requires size1 <= size2 /\ size2 <= 60)
(ensures
FStar.Seq.Base.equal (Vale.AES.AES_BE_s.expand_key Vale.AES.AES_common_s.AES_256 key size1)
(FStar.Seq.Base.slice (Vale.AES.AES_BE_s.expand_key Vale.AES.AES_common_s.AES_256
key
size2)
0
size1))
(decreases size2) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Vale.AES.AES_BE_s.aes_key_word",
"Vale.AES.AES_common_s.AES_256",
"Prims.nat",
"Prims.op_LessThan",
"Vale.AES.AES256_helpers_BE.lemma_expand_append",
"Prims.op_Subtraction",
"Prims.bool",
"Prims.unit",
"Vale.AES.AES_BE_s.expand_key_reveal",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.squash",
"FStar.Seq.Base.equal",
"Vale.Def.Types_s.nat32",
"Vale.AES.AES_BE_s.expand_key",
"FStar.Seq.Base.slice",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_expand_append (key: aes_key_word AES_256) (size1 size2: nat)
: Lemma (requires size1 <= size2 /\ size2 <= 60)
(ensures equal (expand_key AES_256 key size1) (slice (expand_key AES_256 key size2) 0 size1))
(decreases size2) =
| expand_key_reveal ();
if size1 < size2 then lemma_expand_append key size1 (size2 - 1) | false |
FStar.Int8.fsti | FStar.Int8.lt | val lt (a b: t) : Tot bool | val lt (a b: t) : Tot bool | let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 117,
"start_col": 0,
"start_line": 117
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> b: FStar.Int8.t -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.Int8.t",
"FStar.Int.lt",
"FStar.Int8.n",
"FStar.Int8.v",
"Prims.bool"
] | [] | false | false | false | true | false | let lt (a b: t) : Tot bool =
| lt #n (v a) (v b) | false |
Vale.AES.AES256_helpers_BE.fst | Vale.AES.AES256_helpers_BE.lemma_simd_round_key | val lemma_simd_round_key (prev0 prev1:quad32) (rcon:nat32) (round:int) : Lemma
(simd_round_key_256 prev0 prev1 rcon round == round_key_256_rcon prev0 prev1 rcon round) | val lemma_simd_round_key (prev0 prev1:quad32) (rcon:nat32) (round:int) : Lemma
(simd_round_key_256 prev0 prev1 rcon round == round_key_256_rcon prev0 prev1 rcon round) | let lemma_simd_round_key (prev0 prev1:quad32) (rcon:nat32) (round:int) =
quad32_xor_reveal ();
commute_rot_word_sub_word prev1.lo0 rcon;
Vale.Arch.Types.xor_lemmas () | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers_BE.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 84,
"start_col": 0,
"start_line": 81
} | module Vale.AES.AES256_helpers_BE
let lemma_reveal_expand_key_256 (key:aes_key_word AES_256) (round:nat) : Lemma
(expand_key_256 key round == (
if round = 0 then Mkfour key.[3] key.[2] key.[1] key.[0]
else if round = 1 then Mkfour key.[7] key.[6] key.[5] key.[4]
else round_key_256 (expand_key_256 key (round - 2)) (expand_key_256 key (round - 1)) round
))
=
expand_key_256_reveal ()
#reset-options "--fuel 8 --ifuel 0"
let lemma_expand_key_256_0 (key:aes_key_word AES_256) : Lemma
(equal key (expand_key AES_256 key 8))
=
expand_key_reveal ()
open FStar.Mul
#reset-options "--fuel 1 --ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'"
let lemma_expand_key_256_i (key:aes_key_word AES_256) (i:nat) : Lemma
(requires
1 < i /\ i < 15
)
(ensures (
let m = 4 * (i - 2) in
let n = 4 * i in
let v = expand_key AES_256 key n in // Current
let w = expand_key AES_256 key (n + 4) in // Next 4 words
let prev0 = Mkfour v.[m + 3] v.[m + 2] v.[m + 1] v.[m + 0] in // Penultimate 4 words in Current
let prev1 = Mkfour v.[m + 7] v.[m + 6] v.[m + 5] v.[m + 4] in // Ultimate 4 words in Current
round_key_256 prev0 prev1 i == Mkfour w.[n + 3] w.[n + 2] w.[n + 1] w.[n + 0] // NextQuad == Next 4 words
))
=
expand_key_reveal ();
let n = 4 * i in
// unfold expand_key 8 times (could use fuel, but that unfolds everything):
let _ = expand_key AES_256 key (n + 1) in
let _ = expand_key AES_256 key (n + 2) in
let _ = expand_key AES_256 key (n + 3) in
let _ = expand_key AES_256 key (n + 4) in
if i < 14 then (
let _ = expand_key AES_256 key (n + 5) in
let _ = expand_key AES_256 key (n + 6) in
let _ = expand_key AES_256 key (n + 7) in
()
) else ();
()
#reset-options
// expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument
let rec lemma_expand_append (key:aes_key_word AES_256) (size1:nat) (size2:nat) : Lemma
(requires size1 <= size2 /\ size2 <= 60)
(ensures equal (expand_key AES_256 key size1) (slice (expand_key AES_256 key size2) 0 size1))
(decreases size2)
=
expand_key_reveal ();
if size1 < size2 then lemma_expand_append key size1 (size2 - 1)
// quad32 key expansion is equivalent to nat32 key expansion
let rec lemma_expand_key_256 (key:seq nat32) (size:nat) =
lemma_expand_append key (4 * size) 60;
if size = 0 then () else
let i = size - 1 in
lemma_expand_key_256 key i;
lemma_reveal_expand_key_256 key i;
if i < 2 then
(
lemma_expand_append key 4 60;
lemma_expand_append key 8 60;
lemma_expand_key_256_0 key
)
else
(
lemma_expand_append key (4 * i) 60;
lemma_expand_key_256 key (i - 1);
lemma_expand_key_256_i key i
)
// SIMD version of round_key_256 is equivalent to scalar round_key_256 | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.AES.AES256_helpers_BE.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": 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": 3,
"initial_ifuel": 3,
"max_fuel": 3,
"max_ifuel": 3,
"no_plugins": false,
"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 |
prev0: Vale.Def.Types_s.quad32 ->
prev1: Vale.Def.Types_s.quad32 ->
rcon: Vale.Def.Types_s.nat32 ->
round: Prims.int
-> FStar.Pervasives.Lemma
(ensures
Vale.AES.AES256_helpers_BE.simd_round_key_256 prev0 prev1 rcon round ==
Vale.AES.AES256_helpers_BE.round_key_256_rcon prev0 prev1 rcon round) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.nat32",
"Prims.int",
"Vale.Arch.Types.xor_lemmas",
"Prims.unit",
"Vale.AES.AES_BE_s.commute_rot_word_sub_word",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.quad32_xor_reveal"
] | [] | true | false | true | false | false | let lemma_simd_round_key (prev0 prev1: quad32) (rcon: nat32) (round: int) =
| quad32_xor_reveal ();
commute_rot_word_sub_word prev1.lo0 rcon;
Vale.Arch.Types.xor_lemmas () | false |
FStar.Int8.fsti | FStar.Int8.lte | val lte (a b: t) : Tot bool | val lte (a b: t) : Tot bool | let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 51,
"end_line": 118,
"start_col": 0,
"start_line": 118
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> b: FStar.Int8.t -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.Int8.t",
"FStar.Int.lte",
"FStar.Int8.n",
"FStar.Int8.v",
"Prims.bool"
] | [] | false | false | false | true | false | let lte (a b: t) : Tot bool =
| lte #n (v a) (v b) | false |
Vale.AES.AES256_helpers_BE.fst | Vale.AES.AES256_helpers_BE.lemma_expand_key_256_0 | val lemma_expand_key_256_0 (key: aes_key_word AES_256)
: Lemma (equal key (expand_key AES_256 key 8)) | val lemma_expand_key_256_0 (key: aes_key_word AES_256)
: Lemma (equal key (expand_key AES_256 key 8)) | let lemma_expand_key_256_0 (key:aes_key_word AES_256) : Lemma
(equal key (expand_key AES_256 key 8))
=
expand_key_reveal () | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers_BE.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 16,
"start_col": 0,
"start_line": 13
} | module Vale.AES.AES256_helpers_BE
let lemma_reveal_expand_key_256 (key:aes_key_word AES_256) (round:nat) : Lemma
(expand_key_256 key round == (
if round = 0 then Mkfour key.[3] key.[2] key.[1] key.[0]
else if round = 1 then Mkfour key.[7] key.[6] key.[5] key.[4]
else round_key_256 (expand_key_256 key (round - 2)) (expand_key_256 key (round - 1)) round
))
=
expand_key_256_reveal () | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.AES.AES256_helpers_BE.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": 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": 8,
"initial_ifuel": 0,
"max_fuel": 8,
"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 | key: Vale.AES.AES_BE_s.aes_key_word Vale.AES.AES_common_s.AES_256
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal key (Vale.AES.AES_BE_s.expand_key Vale.AES.AES_common_s.AES_256 key 8)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.AES.AES_BE_s.aes_key_word",
"Vale.AES.AES_common_s.AES_256",
"Vale.AES.AES_BE_s.expand_key_reveal",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"FStar.Seq.Base.equal",
"Vale.Def.Types_s.nat32",
"Vale.AES.AES_BE_s.expand_key",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let lemma_expand_key_256_0 (key: aes_key_word AES_256)
: Lemma (equal key (expand_key AES_256 key 8)) =
| expand_key_reveal () | false |
FStar.Int8.fsti | FStar.Int8.op_Slash_Hat | val op_Slash_Hat : a: FStar.Int8.t -> b: FStar.Int8.t{FStar.Int8.v b <> 0} -> Prims.Pure FStar.Int8.t | let op_Slash_Hat = div | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 29,
"end_line": 124,
"start_col": 7,
"start_line": 124
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> b: FStar.Int8.t{FStar.Int8.v b <> 0} -> Prims.Pure FStar.Int8.t | Prims.Pure | [] | [] | [
"FStar.Int8.div"
] | [] | false | false | false | false | false | let op_Slash_Hat =
| div | false |
|
FStar.Int8.fsti | FStar.Int8.op_Subtraction_Hat | val op_Subtraction_Hat : a: FStar.Int8.t -> b: FStar.Int8.t -> Prims.Pure FStar.Int8.t | let op_Subtraction_Hat = sub | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 35,
"end_line": 122,
"start_col": 7,
"start_line": 122
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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 *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> b: FStar.Int8.t -> Prims.Pure FStar.Int8.t | Prims.Pure | [] | [] | [
"FStar.Int8.sub"
] | [] | false | false | false | false | false | let op_Subtraction_Hat =
| sub | false |
|
FStar.Int8.fsti | FStar.Int8.op_Star_Hat | val op_Star_Hat : a: FStar.Int8.t -> b: FStar.Int8.t -> Prims.Pure FStar.Int8.t | let op_Star_Hat = mul | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 28,
"end_line": 123,
"start_col": 7,
"start_line": 123
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> b: FStar.Int8.t -> Prims.Pure FStar.Int8.t | Prims.Pure | [] | [] | [
"FStar.Int8.mul"
] | [] | false | false | false | false | false | let op_Star_Hat =
| mul | false |
|
FStar.Int8.fsti | FStar.Int8.op_Plus_Hat | val op_Plus_Hat : a: FStar.Int8.t -> b: FStar.Int8.t -> Prims.Pure FStar.Int8.t | let op_Plus_Hat = add | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 28,
"end_line": 121,
"start_col": 7,
"start_line": 121
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> b: FStar.Int8.t -> Prims.Pure FStar.Int8.t | Prims.Pure | [] | [] | [
"FStar.Int8.add"
] | [] | false | false | false | false | false | let op_Plus_Hat =
| add | false |
|
FStar.Int8.fsti | FStar.Int8.op_Hat_Hat | val op_Hat_Hat : x: FStar.Int8.t -> y: FStar.Int8.t -> Prims.Pure FStar.Int8.t | let op_Hat_Hat = logxor | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 126,
"start_col": 7,
"start_line": 126
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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 | x: FStar.Int8.t -> y: FStar.Int8.t -> Prims.Pure FStar.Int8.t | Prims.Pure | [] | [] | [
"FStar.Int8.logxor"
] | [] | false | false | false | false | false | let op_Hat_Hat =
| logxor | false |
|
FStar.Int8.fsti | FStar.Int8.op_Percent_Hat | val op_Percent_Hat : a: FStar.Int8.t -> b: FStar.Int8.t{FStar.Int8.v b <> 0} -> Prims.Pure FStar.Int8.t | let op_Percent_Hat = rem | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 31,
"end_line": 125,
"start_col": 7,
"start_line": 125
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> b: FStar.Int8.t{FStar.Int8.v b <> 0} -> Prims.Pure FStar.Int8.t | Prims.Pure | [] | [] | [
"FStar.Int8.rem"
] | [] | false | false | false | false | false | let op_Percent_Hat =
| rem | false |
|
Vale.AES.AES256_helpers_BE.fst | Vale.AES.AES256_helpers_BE.lemma_expand_key_256 | val lemma_expand_key_256 (key:seq nat32) (size:nat) : Lemma
(requires size <= 15 /\ is_aes_key_word AES_256 key)
(ensures (
let s = key_schedule_to_round_keys size (expand_key AES_256 key 60) in
(forall (i:nat).{:pattern (expand_key_256 key i)} i < size ==> expand_key_256 key i == s.[i])
)) | val lemma_expand_key_256 (key:seq nat32) (size:nat) : Lemma
(requires size <= 15 /\ is_aes_key_word AES_256 key)
(ensures (
let s = key_schedule_to_round_keys size (expand_key AES_256 key 60) in
(forall (i:nat).{:pattern (expand_key_256 key i)} i < size ==> expand_key_256 key i == s.[i])
)) | let rec lemma_expand_key_256 (key:seq nat32) (size:nat) =
lemma_expand_append key (4 * size) 60;
if size = 0 then () else
let i = size - 1 in
lemma_expand_key_256 key i;
lemma_reveal_expand_key_256 key i;
if i < 2 then
(
lemma_expand_append key 4 60;
lemma_expand_append key 8 60;
lemma_expand_key_256_0 key
)
else
(
lemma_expand_append key (4 * i) 60;
lemma_expand_key_256 key (i - 1);
lemma_expand_key_256_i key i
) | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers_BE.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 77,
"start_col": 0,
"start_line": 60
} | module Vale.AES.AES256_helpers_BE
let lemma_reveal_expand_key_256 (key:aes_key_word AES_256) (round:nat) : Lemma
(expand_key_256 key round == (
if round = 0 then Mkfour key.[3] key.[2] key.[1] key.[0]
else if round = 1 then Mkfour key.[7] key.[6] key.[5] key.[4]
else round_key_256 (expand_key_256 key (round - 2)) (expand_key_256 key (round - 1)) round
))
=
expand_key_256_reveal ()
#reset-options "--fuel 8 --ifuel 0"
let lemma_expand_key_256_0 (key:aes_key_word AES_256) : Lemma
(equal key (expand_key AES_256 key 8))
=
expand_key_reveal ()
open FStar.Mul
#reset-options "--fuel 1 --ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'"
let lemma_expand_key_256_i (key:aes_key_word AES_256) (i:nat) : Lemma
(requires
1 < i /\ i < 15
)
(ensures (
let m = 4 * (i - 2) in
let n = 4 * i in
let v = expand_key AES_256 key n in // Current
let w = expand_key AES_256 key (n + 4) in // Next 4 words
let prev0 = Mkfour v.[m + 3] v.[m + 2] v.[m + 1] v.[m + 0] in // Penultimate 4 words in Current
let prev1 = Mkfour v.[m + 7] v.[m + 6] v.[m + 5] v.[m + 4] in // Ultimate 4 words in Current
round_key_256 prev0 prev1 i == Mkfour w.[n + 3] w.[n + 2] w.[n + 1] w.[n + 0] // NextQuad == Next 4 words
))
=
expand_key_reveal ();
let n = 4 * i in
// unfold expand_key 8 times (could use fuel, but that unfolds everything):
let _ = expand_key AES_256 key (n + 1) in
let _ = expand_key AES_256 key (n + 2) in
let _ = expand_key AES_256 key (n + 3) in
let _ = expand_key AES_256 key (n + 4) in
if i < 14 then (
let _ = expand_key AES_256 key (n + 5) in
let _ = expand_key AES_256 key (n + 6) in
let _ = expand_key AES_256 key (n + 7) in
()
) else ();
()
#reset-options
// expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument
let rec lemma_expand_append (key:aes_key_word AES_256) (size1:nat) (size2:nat) : Lemma
(requires size1 <= size2 /\ size2 <= 60)
(ensures equal (expand_key AES_256 key size1) (slice (expand_key AES_256 key size2) 0 size1))
(decreases size2)
=
expand_key_reveal ();
if size1 < size2 then lemma_expand_append key size1 (size2 - 1) | {
"checked_file": "/",
"dependencies": [
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Vale.AES.AES256_helpers_BE.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": 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 | key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> size: Prims.nat
-> FStar.Pervasives.Lemma
(requires size <= 15 /\ Vale.AES.AES_BE_s.is_aes_key_word Vale.AES.AES_common_s.AES_256 key)
(ensures
(let s =
Vale.AES.AES_BE_s.key_schedule_to_round_keys size
(Vale.AES.AES_BE_s.expand_key Vale.AES.AES_common_s.AES_256 key 60)
in
forall (i: Prims.nat). {:pattern Vale.AES.AES256_helpers_BE.expand_key_256 key i}
i < size ==> Vale.AES.AES256_helpers_BE.expand_key_256 key i == s.[ i ])) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.op_LessThan",
"Vale.AES.AES256_helpers_BE.lemma_expand_key_256_0",
"Prims.unit",
"Vale.AES.AES256_helpers_BE.lemma_expand_append",
"Vale.AES.AES256_helpers_BE.lemma_expand_key_256_i",
"Vale.AES.AES256_helpers_BE.lemma_expand_key_256",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Vale.AES.AES256_helpers_BE.lemma_reveal_expand_key_256"
] | [
"recursion"
] | false | false | true | false | false | let rec lemma_expand_key_256 (key: seq nat32) (size: nat) =
| lemma_expand_append key (4 * size) 60;
if size = 0
then ()
else
let i = size - 1 in
lemma_expand_key_256 key i;
lemma_reveal_expand_key_256 key i;
if i < 2
then
(lemma_expand_append key 4 60;
lemma_expand_append key 8 60;
lemma_expand_key_256_0 key)
else
(lemma_expand_append key (4 * i) 60;
lemma_expand_key_256 key (i - 1);
lemma_expand_key_256_i key i) | false |
FStar.Int8.fsti | FStar.Int8.op_Less_Less_Hat | val op_Less_Less_Hat : a: FStar.Int8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.Int8.t | let op_Less_Less_Hat = shift_left | {
"file_name": "ulib/FStar.Int8.fsti",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 129,
"start_col": 7,
"start_line": 129
} | (*
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.Int8
(**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****)
unfold let n = 8
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 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Int8.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.Int8.t -> s: FStar.UInt32.t -> Prims.Pure FStar.Int8.t | Prims.Pure | [] | [] | [
"FStar.Int8.shift_left"
] | [] | false | false | false | false | false | let op_Less_Less_Hat =
| shift_left | false |
|
InterpreterTarget.fsti | InterpreterTarget.allow_reader_of_dtyp | val allow_reader_of_dtyp (d: dtyp) : Tot bool | val allow_reader_of_dtyp (d: dtyp) : Tot bool | let allow_reader_of_dtyp (d: dtyp) : Tot bool =
match d with
| DT_IType i -> allow_reader_of_itype i
| DT_App readable _ _ -> readable | {
"file_name": "src/3d/InterpreterTarget.fsti",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 35,
"end_line": 61,
"start_col": 0,
"start_line": 58
} | (*
Copyright 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 InterpreterTarget
(* The abstract syntax for the code produced by 3d, targeting prelude/Interpreter.fst *)
open FStar.All
module A = Ast
module T = Target
open Binding
let expr = T.expr
let action = T.action
let lam a = A.ident & a
type itype =
| UInt8
| UInt16
| UInt32
| UInt64
| UInt8BE
| UInt16BE
| UInt32BE
| UInt64BE
| Unit
| AllBytes
| AllZeros
let allow_reader_of_itype (i:itype)
: bool
= match i with
| AllBytes
| AllZeros -> false
| _ -> true
let readable_itype = (i: itype { allow_reader_of_itype i == true })
noeq
type dtyp : Type =
| DT_IType:
i:itype -> dtyp
| DT_App:
readable: bool ->
hd:A.ident ->
args:list expr ->
dtyp | {
"checked_file": "/",
"dependencies": [
"Target.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked",
"Binding.fsti.checked",
"Ast.fst.checked"
],
"interface_file": false,
"source_file": "InterpreterTarget.fsti"
} | [
{
"abbrev": false,
"full_module": "Binding",
"short_module": null
},
{
"abbrev": true,
"full_module": "Target",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "Ast",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": 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 | d: InterpreterTarget.dtyp -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"InterpreterTarget.dtyp",
"InterpreterTarget.itype",
"InterpreterTarget.allow_reader_of_itype",
"Prims.bool",
"Ast.ident",
"Prims.list",
"InterpreterTarget.expr"
] | [] | false | false | false | true | false | let allow_reader_of_dtyp (d: dtyp) : Tot bool =
| match d with
| DT_IType i -> allow_reader_of_itype i
| DT_App readable _ _ -> readable | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.